Docker is a free and open-source containerization platform that allows developers to package applications into containers. Docker uses OS-level virtualization to deliver software in packages called containers. It allows you to create, build, and run lightweight, portable application images for any platform.
Docker Compose is a free and open-source tool that helps you define and share multi-container applications in a single YAML file. With Docker Compose, you can run and connect multiple containers as a single service.
This post will show you how to install Docker and Docker Compose in Oracle Linux 8.
In This Article
- Update Oracle Linux Server
- Install Docker CE (Community Edition)
- Verify Docker Installation
- Install Docker Compose
- Remove Docker and Docker Compose
Step 1 – Update Oracle Linux Server
Note: It is recommended that your Oracle Linux 8 server has at least 4GB RAM.
Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.
Once you are logged in to your server, run the following command to update your base system with the latest available packages.
dnf update -y
Step 2 – Install Docker CE (Community Edition)
By default, the latest version of the Docker package is not included in the Oracle Linux default repository, so you will need to create a Docker CE repo.
You can create it using the following command:
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Next, run the following command to install Docker CE on your server.
dnf install docker-ce -y
After the installation, start the Docker service and enable it to start at system reboot.
systemctl start docker systemctl enable docker
Next, verify the running status of the Docker service using the following command:
systemctl status docker
● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since Sat 2022-04-30 08:35:46 EDT; 6s ago Docs: https://docs.docker.com Main PID: 8554 (dockerd) Tasks: 8 Memory: 31.7M CGroup: /system.slice/docker.service └─8554 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock Apr 30 08:35:45 oraclelinux dockerd: time="2022-04-30T08:35:45.932297676-04:00" level=error msg="Failed to built-in GetDriver graph btr> Apr 30 08:35:46 oraclelinux dockerd: time="2022-04-30T08:35:46.249687493-04:00" level=warning msg="Your kernel does not support cgroup > Apr 30 08:35:46 oraclelinux dockerd: time="2022-04-30T08:35:46.249732672-04:00" level=warning msg="Your kernel does not support cgroup > Apr 30 08:35:46 oraclelinux dockerd: time="2022-04-30T08:35:46.249960144-04:00" level=info msg="Loading containers: start." Apr 30 08:35:46 oraclelinux dockerd: time="2022-04-30T08:35:46.682620546-04:00" level=info msg="Default bridge (docker0) is assigned wi> Apr 30 08:35:46 oraclelinux dockerd: time="2022-04-30T08:35:46.861304346-04:00" level=info msg="Loading containers: done." Apr 30 08:35:46 oraclelinux dockerd: time="2022-04-30T08:35:46.884014323-04:00" level=info msg="Docker daemon" commit=87a90dc graphdriv> Apr 30 08:35:46 oraclelinux dockerd: time="2022-04-30T08:35:46.884186171-04:00" level=info msg="Daemon has completed initialization" Apr 30 08:35:46 oraclelinux systemd: Started Docker Application Container Engine. Apr 30 08:35:46 oraclelinux dockerd: time="2022-04-30T08:35:46.934543023-04:00" level=info msg="API listen on /var/run/docker.sock"
You can also verify the Docker version with additional information using the following command:
You will get the following output:
Client: Context: default Debug Mode: false Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Docker Buildx (Docker Inc., v0.8.1-docker) scan: Docker Scan (Docker Inc., v0.17.0) Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 20.10.14 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins:
Step 3 – Verify Docker Installation
At this point, Docker is installed and running. Now it’s time to test whether it’s working or not.
You can download and run Docker’s hello-world container to test Docker.
docker run hello-world
This will download and run the hello-world Docker container on your system:
latest: Pulling from library/hello-world 2db29710123e: Pull complete Digest: sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67 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/
You can use the “docker images” command to verify the downloaded image:
You will get the following output:
REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 7 months ago 13.3kB
Step 4 – Install Docker Compose
By default, the latest Docker Compose version is unavailable in the Oracle Linux default repository, so you will need to download it from the Git Hub repository.
First, install the curl command utility with the following command:
dnf install -y curl
Next, download the latest version of Docker Compose using the following command:
curl -L https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
Next, set executable permission on the Docker Compose binary:
chmod +x /usr/local/bin/docker-compose
Next, verify the Docker Compose version using the following command:
You will get the following output:
Docker Compose version v2.21.0
Step 5 – Remove Docker and Docker Compose
If you want to remove the Docker package from your system, you will need to stop the Docker service first:
systemctl stop docker
Next, remove the Docker package using the following command:
dnf remove docker-ce -y
To remove Docker Compose, delete the Docker Compose binary using the following command:
rm -rf /usr/local/bin/docker-compose
You learned how to install Docker and Docker Compose on Oracle Linux 8 in this guide. You can now install both on your development environment and deploy an application in the Docker environment. Give it a try on your dedicated server from Atlantic.Net!