The Nautilus DevOps team is preparing to containerize various applications. Following a recent meeting with the application development team, the goal is to set up Docker on App Server 2 for testing purposes. This includes:
- Installing
docker-ce
anddocker-compose
packages. - Starting the Docker service to ensure it is operational.
First, install yum-utils
, which provides utilities to manage Yum repositories and packages.
sudo yum install -y yum-utils
Add the Docker repository to the Yum package manager, and then install Docker and Docker Compose packages.
-
Add Docker Repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
This command configures Yum to use the Docker repository for installation.
-
Install Docker and Docker Compose
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
This command installs the following packages:
docker-ce
: Docker Community Editiondocker-ce-cli
: Docker command-line interfacecontainerd.io
: Containerd runtimedocker-buildx-plugin
: Docker buildx plugin for advanced build capabilitiesdocker-compose-plugin
: Docker Compose plugin for defining and running multi-container applications
Start the Docker service to initialize Docker and enable it to start automatically on system boot.
sudo systemctl start docker
-
Enable Docker to Start at Boot
Optionally, you can enable Docker to start automatically on boot by running:
sudo systemctl enable docker
To confirm that Docker is installed correctly and the service is running, execute a test container.
sudo docker run hello-world
This command runs the hello-world
Docker image, which outputs a message indicating that Docker is working correctly. The expected output should include a message like:
Hello from Docker!
This message shows that your installation appears to be working correctly.