.
What is a Container
- A container is a self-contained ready-to-run application
- This is what makes it different from a virtual machine!
- Containers have all on board that is required to start the application
- To start a container, a container runtime is required
- The container runtime is running on a host platform and establishes communication between the local host kernel and the container
- So, all containers, no matter what they do, run on top
of the same local host kernel
Container Components
- Images are read-only environments that contain the runtime environment, which includes the application and all libraries it requires
- Containers are the isolated runtime environments where the application is running. By using namespaces the containers can be offered as a strictly isolated environment
- Registries are used to store images. Docker Hub is a common registry, other registries exist (like quay.io) and private registries can be created also
Containers are Linux!
- Containers are based on features offered by the Linux
operating system - Linux Kernel Namespaces provide strict isolation between system components at different levels
- network
- file
- users
- processes
- IPCs
- Linux CGroups offer resource allocation and limitation
Container Runtimes
- The container runtime allows for starting and running the container on top of the host OS
- The container runtime is responsible for all parts of running the container which are not already a part of the running container program itself
- Different container runtime solutions exist
- docker
- Ixc
- runc
- cri-o
- containerd
- These runtimes are included in the different container solutions
The OCI
- OCI is the Open Containers Initiative (https://opencontainers.org)
- It standardizes the use of containers
- The image-spec defines how to package a container in a “filesystem bundle”
- The runtime-spec defines how to run that filesystem in a container
- OCI standardization ensures compatibility between containers, no matter which environment they originally come from
- The result is that for instance images made for Docker work without modifications in Red Hat Podman
Docker
- Docker is important in the container landscape, but Docker is NOT the only way to run containers
- When it started in 2013, Docker offered the following:
- Container image format
- Dockerfile, which is a method for building container images
- A way to manage container images
- A way to run containers
- A way to manage container instances
- A solution to share container images
- Podman is the main alternative to Docker
Alternatives to Docker
- With the launch of RHEL 8, Red Hat started offering Podman as an alternative to Docker
- Podman runs containers without the need of having a daemon directly on top of the cri-o container runtime
- Buildah is the related service that is used for managing container images
- Other solutions for running containers also exist
- LXC is a Linux-native container runtime
- systemd-nspawn offers containers integrated in Systemd
Registries
- Container registries are used to provide access to container images
- Registries make distribution of containers easier: anyone can publish images on public registries
- Docker Hub (hub.docker.com) is the biggest registry
- Other registries exist as well, like quay.io
- It’s also possible to create private registries
Accessing Registries
- Access to registries is normally free
- In some cases, additional authorization is required and you’ll need an account to access registry contents
- On Docker Hub, an account gives access to additional features
- Higher image pull limit
- Web hooks connecting to GitHub
- Use the browser-based login, or
docker login
from the command line
Starting Containers
- Many environments are available, let’s look at Docker
- To use containers on RHEL 8 and related distributions, you can use podman instead of docker
- Use
dnf install -y container-tools
to install podman and related utilities
Installing Docker on Ubuntu
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint OEBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(Isb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world
Running a Container
mkdir -p /var/www/html
echo hello from docker >> /var/www/html/index.html
docker run -d -p 8080:80 --name="myapache" -v /var/www/html:/var/www/html httpd
docker ps
ss -tunap | grep 8080
curl http://localhost:8080
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
[root@controller /]# mkdir -p /var/www/html [root@controller /]# echo hello from docker >> /var/www/html/index.html [root@controller /]# cat /var/www/html/index.html hello from docker [root@controller /]# docker run -d -p 8080:80 --name="myapache" -v /var/www/html:/var/www/html httpd Unable to find image 'httpd:latest' locally latest: Pulling from library/httpd e1caac4eb9d2: Pull complete 87b0fe460fd9: Pull complete 4f4fb700ef54: Pull complete 9cebd3e3b523: Pull complete e9304da947c5: Pull complete b60d4b66b268: Pull complete Digest: sha256:104f07de17ee186c8f37b9f561e04fbfe4cf080d78c6e5f3802fd08fd118c3da Status: Downloaded newer image for httpd:latest 132a8601bc20a2fa997a19438087c412c049f6ea39dfbe7e7591aeb19f50269a [root@controller /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 132a8601bc20 httpd "httpd-foreground" 37 seconds ago Up 34 seconds 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache [root@controller /]# ss -tunap | grep 8080 tcp LISTEN 0 2048 0.0.0.0:8080 0.0.0.0:* users:(("docker-proxy",pid=346482,fd=4)) tcp LISTEN 0 2048 [::]:8080 [::]:* users:(("docker-proxy",pid=346490,fd=4)) [root@controller /]# curl http://localhost:8080 <html><body><h1>It works!</h1></body></html> |
Running Another Container
docker run -it busybox
will start the busybox container with an interactive terminal to the entrypoint applicationCtrl-p, Ctrl-q
to disconnect and keep it runningexit
to stop the current container application- If you were connected to the entrypoint application, the container will stop
- If you were connected to another shell session, the container will continue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
[root@controller /]# docker run -it busybox Unable to find image 'busybox:latest' locally latest: Pulling from library/busybox 9ad63333ebc9: Pull complete Digest: sha256:6d9ac9237a84afe1516540f40a0fafdc86859b2141954b4d643af7066d598b74 Status: Downloaded newer image for busybox:latest / # ps PID USER TIME COMMAND 1 root 0:00 sh 7 root 0:00 ps / # ps aux PID USER TIME COMMAND 1 root 0:00 sh 8 root 0:00 ps aux / # exit [root@controller /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 132a8601bc20 httpd "httpd-foreground" 11 minutes ago Up 11 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache [root@controller /]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9107d90d8447 busybox "sh" About a minute ago Exited (0) 10 seconds ago youthful_chandrasekhar 132a8601bc20 httpd "httpd-foreground" 11 minutes ago Up 11 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache 605cd349b37c hello-world "/hello" About an hour ago Exited (0) About an hour ago nervous_keldysh 0d6983933a50 hello-world "/hello" 12 hours ago Exited (0) 12 hours ago serene_curie [root@controller /]# docker run -it busybox / # <ctrl+p><ctrl+q> [root@controller /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a96d522c5b20 busybox "sh" 45 seconds ago Up 44 seconds cool_pasteur 132a8601bc20 httpd "httpd-foreground" 12 minutes ago Up 12 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache [root@controller /]# docker exec -it myapache sh # ps aux sh: 1: ps: not found # ls /proc 1 acpi cpuinfo execdomains ioports kmsg mdstat net self sysrq-trigger version 10 buddyinfo crypto fb irq kpagecgroup meminfo pagetypeinfo slabinfo sysvipc vmallocinfo 8 bus devices filesystems kallsyms kpagecount misc partitions softirqs thread-self vmstat 9 cgroups diskstats fs kcore kpageflags modules sched_debug stat timer_list xen 92 cmdline dma interrupts key-users loadavg mounts schedstat swaps tty zoneinfo 98 consoles driver iomem keys locks mtrr scsi sys uptime # cat /proc/1/cmdline httpd-DFOREGROUND # exit [root@controller /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a96d522c5b20 busybox "sh" 3 minutes ago Up 3 minutes cool_pasteur 132a8601bc20 httpd "httpd-foreground" 15 minutes ago Up 15 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache |
Managing Containers – Common Commands
docker ps [-a]
: shows currently [and past] running containersdocker start
: starts a container from a locally stored imagedocker stop
: stops a container using Linux SIGTERMdocker restart
: restarts a currently running containerdocker kill
: stops a container using Linux SIGKILLdocker rm
: removes all container files from the host operating system
Inspecting Container Settings
docker ps
will show the IDs of containers: pick one!docker inspect <ID> | less
docker inspect --format='{{.NetworkSettings.IPAddress}}' containername
docker inspect --format ='{{.State.Pid}}' containername
- Alternatively, use
ps aux
on the host to find the container PID
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
[root@controller /]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a96d522c5b20 busybox "sh" 33 minutes ago Up 33 minutes cool_pasteur 9107d90d8447 busybox "sh" 35 minutes ago Exited (0) 34 minutes ago youthful_chandrasekhar 132a8601bc20 httpd "httpd-foreground" 45 minutes ago Up 45 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache 605cd349b37c hello-world "/hello" 2 hours ago Exited (0) 2 hours ago nervous_keldysh 0d6983933a50 hello-world "/hello" 13 hours ago Exited (0) 13 hours ago serene_curie [root@controller /]# docker inspect youthful_chandrasekhar | more [ { "Id": "9107d90d8447d0f70238eb121660e4db746048d37d3294dd3ec0e8215006752b", "Created": "2024-02-20T10:02:35.922550351Z", "Path": "sh", "Args": [], "State": { "Status": "exited", "Running": false, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 0, "ExitCode": 0, "Error": "", "StartedAt": "2024-02-20T10:02:36.401131212Z", "FinishedAt": "2024-02-20T10:04:14.878553209Z" }, ... [root@controller /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a96d522c5b20 busybox "sh" 33 minutes ago Up 33 minutes cool_pasteur 132a8601bc20 httpd "httpd-foreground" 45 minutes ago Up 45 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache [root@controller /]# docker inspect cool_pasteur | more [ { "Id": "a96d522c5b2095c33aa647f52807727831b161815937f0500941e685f22f8a00", "Created": "2024-02-20T10:05:07.9709231Z", "Path": "sh", "Args": [], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 349943, "ExitCode": 0, "Error": "", "StartedAt": "2024-02-20T10:05:08.410217942Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:3f57d9401f8d42f986df300f0c69192fc41da28ccc8d797829467780db3dd741", "ResolvConfPath": "/var/lib/docker/containers/a96d522c5b2095c33aa647f52807727831b161815937f0500941e685f22f8a00/resolv.conf", "HostnamePath": "/var/lib/docker/containers/a96d522c5b2095c33aa647f52807727831b161815937f0500941e685f22f8a00/hostname", "HostsPath": "/var/lib/docker/containers/a96d522c5b2095c33aa647f52807727831b161815937f0500941e685f22f8a00/hosts", "LogPath": "/var/lib/docker/containers/a96d522c5b2095c33aa647f52807727831b161815937f0500941e685f22f8a00/a96d522c5b2095c33aa647f52807727831b161815937f0500941e685f22f8a00-json.l og", ... [root@controller /]# docker inspect --format='{{.NetworkSettings.IPAddress}}' cool_pasteur 172.17.0.3 [root@controller /]# docker inspect --format ='{{.State.Pid}}' cool_pasteur =349943 [root@controller /]# ps fax | more PID TTY STAT TIME COMMAND 2 ? S 0:00 [kthreadd] 3 ? I< 0:00 \_ [rcu_gp] 4 ? I< 0:00 \_ [rcu_par_gp] 5 ? I< 0:00 \_ [slub_flushwq] 7 ? I< 0:00 \_ [kworker/0:0H-events_highpri] 10 ? I< 0:00 \_ [mm_percpu_wq] 11 ? S 0:00 \_ [rcu_tasks_rude_] 12 ? S 0:00 \_ [rcu_tasks_trace] 13 ? S 0:00 \_ [ksoftirqd/0] 14 ? I 0:51 \_ [rcu_sched] |
Managing Images
- After fetching, the container images are stored on the host
- Use
docker images
to get a list of images - Or use
docker image --help
to get an overview of all options related to managing container images
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
[root@controller /]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 3f57d9401f8d 4 weeks ago 4.26MB httpd latest 2776f4da9d55 4 weeks ago 167MB hello-world latest d2c94e258dcb 9 months ago 13.3kB [root@controller /]# docker image Usage: docker image COMMAND Manage images Commands: build Build an image from a Dockerfile history Show the history of an image import Import the contents from a tarball to create a filesystem image inspect Display detailed information on one or more images load Load an image from a tar archive or STDIN ls List images prune Remove unused images pull Download an image from a registry push Upload an image to a registry rm Remove one or more images save Save one or more images to a tar archive (streamed to STDOUT by default) tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE [root@controller /]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 3f57d9401f8d 4 weeks ago 4.26MB httpd latest 2776f4da9d55 4 weeks ago 167MB hello-world latest d2c94e258dcb 9 months ago 13.3kB [root@controller /]# docker image inspect 3f57d9401f8d | more [ { "Id": "sha256:3f57d9401f8d42f986df300f0c69192fc41da28ccc8d797829467780db3dd741", "RepoTags": [ "busybox:latest" ], "RepoDigests": [ "busybox@sha256:6d9ac9237a84afe1516540f40a0fafdc86859b2141954b4d643af7066d598b74" ], "Parent": "", "Comment": "buildkit.dockerfile.v0", "Created": "2024-01-17T21:49:12Z", "Container": "", "ContainerConfig": { "Hostname": "", "Domainname": "", ... [root@controller /]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 3f57d9401f8d 4 weeks ago 4.26MB httpd latest 2776f4da9d55 4 weeks ago 167MB hello-world latest d2c94e258dcb 9 months ago 13.3kB [root@controller /]# docker image rm d2c94e258dcb Error response from daemon: conflict: unable to delete d2c94e258dcb (must be forced) - image is being used by stopped container 0d6983933a50 [root@controller /]# docker image rm -f d2c94e258dcb Untagged: hello-world:latest Untagged: hello-world@sha256:d000bc569937abbe195e20322a0bde6b2922d805332fd6d8a68b19f524b7d21d Deleted: sha256:d2c94e258dcb3c5ac2798d32e1249e42ef01cba4841c2234249495f87264ac5a |
Container Logging
- The container application does not connect to a STDOUT, which is why logs,
by default, are written to the container - Use
docker logs mycontainer
to get access to the container log - Using
docker logs
is convenient for troubleshooting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
[root@controller /]# docker run mariadb Unable to find image 'mariadb:latest' locally latest: Pulling from library/mariadb 01007420e9b0: Pull complete 0afd642f34d1: Pull complete 696ca6335161: Pull complete a7e0c48ca7d7: Pull complete 8d9e67098d76: Pull complete 72f5e793adab: Pull complete d5f886ae8a97: Pull complete 7e77db7838e8: Pull complete Digest: sha256:55d9608d84658cbc691f52cd6389386a15e6c671cb5708b9f3af5782af3b4dbb Status: Downloaded newer image for mariadb:latest 2024-02-20 11:21:20+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.2.3+maria~ubu2204 started. 2024-02-20 11:21:21+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup/pids:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 11:cpu,cpuacct:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 10:rdma:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 9:blkio:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 8:memory:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 7:hugetlb:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 6:net_cls,net_prio:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 5:perf_event:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 4:freezer:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 3:devices:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 2:cpuset:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 1:name=systemd:/docker/e8628333ea4940fdcf8352e04b7106be21d9c65c023013f05d52f46ee5b5378a 0:://memory.pressure not writable, functionality unavailable to MariaDB 2024-02-20 11:21:21+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2024-02-20 11:21:21+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.2.3+maria~ubu2204 started. 2024-02-20 11:21:21+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified You need to specify one of MARIADB_ROOT_PASSWORD, MARIADB_ROOT_PASSWORD_HASH, MARIADB_ALLOW_EMPTY_ROOT_PASSWORD and MARIADB_RANDOM_ROOT_PASSWORD [root@controller /]# docker run -d mariadb 3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f [root@controller /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a96d522c5b20 busybox "sh" About an hour ago Up About an hour cool_pasteur 132a8601bc20 httpd "httpd-foreground" About an hour ago Up About an hour 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache [root@controller /]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3429b13ec1e9 mariadb "docker-entrypoint.s…" 17 seconds ago Exited (1) 14 seconds ago trusting_rosalind e8628333ea49 mariadb "docker-entrypoint.s…" 54 seconds ago Exited (1) 48 seconds ago sharp_kowalevski a96d522c5b20 busybox "sh" About an hour ago Up About an hour cool_pasteur 9107d90d8447 busybox "sh" About an hour ago Exited (0) About an hour ago youthful_chandrasekhar 132a8601bc20 httpd "httpd-foreground" About an hour ago Up About an hour 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache 605cd349b37c d2c94e258dcb "/hello" 3 hours ago Exited (0) 3 hours ago nervous_keldysh 0d6983933a50 d2c94e258dcb "/hello" 14 hours ago Exited (0) 14 hours ago serene_curie [root@controller /]# docker logs trusting_rosalind 2024-02-20 11:21:54+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.2.3+maria~ubu2204 started. 2024-02-20 11:21:55+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup/pids:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 11:cpu,cpuacct:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 10:rdma:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 9:blkio:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 8:memory:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 7:hugetlb:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 6:net_cls,net_prio:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 5:perf_event:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 4:freezer:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 3:devices:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 2:cpuset:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 1:name=systemd:/docker/3429b13ec1e95890be2f06714d1a688785be7154453c5f78ef0cca68e995098f 0:://memory.pressure not writable, functionality unavailable to MariaDB 2024-02-20 11:21:55+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2024-02-20 11:21:55+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.2.3+maria~ubu2204 started. 2024-02-20 11:21:55+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified You need to specify one of MARIADB_ROOT_PASSWORD, MARIADB_ROOT_PASSWORD_HASH, MARIADB_ALLOW_EMPTY_ROOT_PASSWORD and MARIADB_RANDOM_ROOT_PASSWORD [root@controller /]# docker run -d --name mydb mariadb -e MYSQL_ROOT_PASSWORD=password 2024-02-20 11:25:50+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.2.3+maria~ubu2204 started. 2024-02-20 11:25:50+00:00 [ERROR] [Entrypoint]: mariadbd failed while attempting to check config command was: mariadbd -e MYSQL_ROOT_PASSWORD=password --verbose --help 2024-02-20 11:25:50 0 [Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text 2024-02-20 11:25:50 0 [ERROR] mariadbd: unknown option '-e' [root@controller /]# docker run -d --name mydb -e MYSQL_ROOT_PASSWORD=password mariadb docker: Error response from daemon: Conflict. The container name "/mydb" is already in use by container "25dfb9b7e1104550fc60ac7f556fb654637ef3457c3be31ae7c148ccb3c4239a". You have to remove (or rename) that container to be able to reuse that name. See 'docker run --help'. [root@controller /]# docker rm mydb mydb [root@controller /]# docker run -d --name mydb -e MYSQL_ROOT_PASSWORD=password mariadb a229ccfd0f818f06b641ca38350e49cb7528732915166c0baeaec16d204cb9bf [root@controller /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a229ccfd0f81 mariadb "docker-entrypoint.s…" 33 seconds ago Up 31 seconds 3306/tcp mydb a96d522c5b20 busybox "sh" About an hour ago Up About an hour cool_pasteur 132a8601bc20 httpd "httpd-foreground" 2 hours ago Up 2 hours 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapache |
Lab: Using Containers
- Run the latest version of Ubuntu in a container
- In interactive mode, start a bash shell and explore the
/etc/os-release
file, as well as the kernel version (uname -r
) - Disconnect from the container without shutting it down
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
[root@controller /]# docker run -it ubuntu:latest Unable to find image 'ubuntu:latest' locally latest: Pulling from library/ubuntu 01007420e9b0: Already exists Digest: sha256:f9d633ff6640178c2d0525017174a688e2c1aef28f0a0130b26bd5554491f0da Status: Downloaded newer image for ubuntu:latest root@cc94dcd26493:/# cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.3 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.3 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy root@cc94dcd26493:/# uname -r 4.18.0-500.el8.x86_64 root@cc94dcd26493:/# <ctrl+p><ctrl+q> [root@controller /]# [root@controller /]# uname -r 4.18.0-500.el8.x86_64 [root@controller /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cc94dcd26493 ubuntu:latest "/bin/bash" About a minute ago Up About a minute sweet_mclean a229ccfd0f81 mariadb "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 3306/tcp mydb a96d522c5b20 busybox "sh" 2 hours ago Up 2 hours cool_pasteur 132a8601bc20 httpd "httpd-foreground" 2 hours ago Up 2 hours 0.0.0.0:8080->80/tcp, :::8080->80/tcp myapac |
As we see the kernel version in the container is alwys the same like in the virtual machine.