We describe the initial setup method as a way to get started with Docker, a platform that uses container-based virtualization technology.
An overview of Docker will be described in another knowledge.
Docker installation
There are two ways to install Docker, and we’ll explain both. They are the method using the shell script on the official website and the installation method using the package management system.
Each method has a slight difference in the latest version that can be installed, but basically the installed Docker is the same. Therefore, you can use any method you like.
We explain two types of how to use the package management system, Ubuntu and CentOS.
Installation method using the shell script provided on the Docker official website
- Download the shell script with the “curl” command and execute it.
curl https://get.docker.com | sh
- If “curl” is not installed, execute the above command after installing it.
Installation using a package management system: Ubuntu
- Update package index.
$ sudo apt-get update
- Install dependent software.
$ sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
- Install Docker official public GPG key.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Confirm that the fingerprint of the key is displayed as “9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88”.
$ sudo apt-key fingerprint 0EBFCD88
- Add repository.
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
- Update package index.
$ sudo apt-get update
- Install Docker.
$ sudo apt-get install -y docker-ce
Installation using a package management system: CentOS
- Install dependent software.
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
- Add repository.
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
- Install Docker.
$ sudo yum install docker-ce
Docker startup confirmation & automatic startup setting
- Create docker group
$ sudo groupadd docker
- Include current user in docker group and set docker command to be executable without sudo.
- This setting will be reflected when you log out and log in again. In this knowledge, we will continue to use sudo.
$ sudo usermod -aG docker $USER
- If you are using CentOS, start Docker.
- If you are using Ubuntu, it is not necessary to execute this command because it starts immediately after installation.
$ sudo systemctl start docker
- In addition, set Docker to start automatically.
$ sudo systemctl enable docker
- Check the installed Docker version./span>
$ docker --version
- Run a Docker image for testing.
- Download the test image and run the container.
$ sudo docker run hello-world
With the above, Docker installation and startup confirmation are completed normally, and it can be used.
The following knowledge describes how to use Docker.