fPaste.me

A free, anonymous, minimalist and open source paste tool.


Troubleshooting Docker on Fedora 32
31-05-2020 06:28:38
DCPagan
# Confer "Install Docker Engine on Fedora" <https://docs.docker.com/engine/install/fedora/>

sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf config-manager --enable docker-ce-stable
# Set releasever=31 because Docker only supports Fedora versions 30 and 31.
sudo dnf --repo=docker-ce-stable --releasever=31 install docker-ce docker-ce-cli containerd.io

# Cgroups Exception: For Fedora 31 and higher, you need to enable the backward compatibility for Cgroups.
sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"

# Start Docker
sudo systemctl enable --now docker

# If you would like to use Docker as a non-root user, you should now consider adding your user to the “docker” group with something like:
sudo usermod -aG docker "${USER}"

# Fix systemd cgroup error: "docker: Error response from daemon: cgroups: cannot found cgroup mount destination: unknown."
# <https://github.com/docker/for-linux/issues/219#issuecomment-375160449>
sudo mkdir /sys/fs/cgroup/systemd
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd

# Client: Docker Engine - Community
# Version: 19.03.10
# API version: 1.40
# Go version: go1.13.10
# Git commit: 9424aeaee9
# Built: Thu May 28 22:17:56 2020
# OS/Arch: linux/amd64
# Experimental: false
#
# Server: Docker Engine - Community
# Engine:
# Version: 19.03.10
# API version: 1.40 (minimum version 1.12)
# Go version: go1.13.10
# Git commit: 9424aeaee9
# Built: Thu May 28 22:15:54 2020
# OS/Arch: linux/amd64
# Experimental: false
# containerd:
# Version: 1.2.13
# GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
# runc:
# Version: 1.0.0-rc10
# GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
# docker-init:
# Version: 0.18.0
# GitCommit: fec3683
docker info

# Commence Docker 101 Tutorial <https://www.docker.com/101-tutorial>
# Chapter 1: "Getting Started"
docker image pull docker/getting-started
docker run -dp 80:80 docker/getting-started

# Tutorial runs fine in http://localhost
xdg-open http://localhost

# Chapter 2: "Our Application"
# Download and extract app.zip from tutorial to project directory
curl -O http://localhost/assets/app.zip
unzip app.zip
rm app.zip

# Commit changes for reference
git init
git add app/
git commit -m 'Extract app.zip from Docker 101 Tutorial'

# Copy Dockerfile verbatim from Docker 101 Tutorial
cat <<EOF >Dockerfile
FROM node:12-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "/app/src/index.js"]
EOF
git add Dockerfile
git commit -m 'Copy Dockerfile verbatim from Docker 101 Tutorial'

# Build and run the app
docker build -t getting-started .
docker run -dp 3000:3000 getting-started

# App exits with the following logs:
# internal/modules/cjs/loader.js:969
# throw err;
# ^
#
# Error: Cannot find module '/app/src/index.js'
# at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
# at Function.Module._load (internal/modules/cjs/loader.js:842:27)
# at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
# at internal/main/run_main_module.js:17:47 {
# code: 'MODULE_NOT_FOUND',
# requireStack: []
# }
docker container list --last 1
docker container logs $appContainerId
docker container logs --follow $appContainerID