What is docker?
Docker is basically a container engine that uses the Linux Kernel in order to create containers on top of an operating system. Which is used to create, deploy and run the applications.
Install the docker using the
apt package manager.
apt install docker.io docker-compose
Start and enable the docker
systemctl enable --now docker
Check Docker service
systemctl status docker
root@ubuntu23:~# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled) Active: active (running) since Wed 2023-10-18 14:56:05 UTC; 2min 53s ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 1959 (dockerd) Tasks: 8 Memory: 23.9M CPU: 876ms CGroup: /system.slice/docker.service └─1959 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.> Oct 18 14:56:04 ubuntu23 systemd: Starting docker.service - Docker Application Cont> Oct 18 14:56:04 ubuntu23 dockerd: time="2023-10-18T14:56:04.444600821Z" level=in>
Create a group called docker,
To add a user to the docker user group
usermod -aG docker $USER
If you want to add a different user, replace
$USER with an existing username.
Check the docker version,
root@ubuntu23:~# docker --version Docker version 24.0.5, build 24.0.5-0ubuntu1
Test docker using the
docker run hello-world
root@ubuntu23:~# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 719385e32844: Pull complete Digest: sha256:88ec0acaa3ec199d3b7eaf73588f4518c25f9d34f58ce9a0df68429c5af48e8d Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/