Set up the repository
- Update the apt package index and install packages to allow apt to use a repository over HTTPS:
-
$ sudo apt-get update $ sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release
- Add Docker’s official GPG key:
-
$ sudo mkdir -p /etc/apt/keyrings $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
- Use the following command to set up the repository:
-
$ echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine
This procedure works for Debian on x86_64 / amd64, armhf, arm64, and Raspbian.
- Update the apt package index, and install the latest version of Docker Engine, containerd, and Docker Compose, or go to the next step to install a specific version:
-
$ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
- To install a specific version of Docker Engine, list the available versions in the repo, then select and install:
$ apt-cache madison docker-ce docker-ce | 5:18.09.1~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages docker-ce | 5:18.09.0~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages docker-ce | 18.06.1~ce~3-0~debian | https://download.docker.com/linux/debian stretch/stable amd64 Packages docker-ce | 18.06.0~ce~3-0~debian | https://download.docker.com/linux/debian stretch/stable amd64 Packages
-
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin
- a. List the versions available in your repo:
- Verify that Docker Engine is installed correctly by running the hello-world image.This command downloads a test imag
-
$ sudo docker run hello-world
To create the docker group and add your user:
- Create the docker group.
-
$ sudo groupadd docker
- Add your user to the docker group.
-
$ sudo usermod -aG docker $USER
- Log out and log back in so that your group membership is re-evaluated.On a desktop Linux environment such as X Windows, log out of your session completely and then log back in.
$ newgrp docker
- On Linux, you can also run the following command to activate the changes to groups:
- If testing on a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.
- Verify that you can run docker commands without sudo.This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.
To fix this problem, either remove the ~/.docker/ directory (it is recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands:WARNING: Error loading config file: /home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied
-
$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R $ sudo chmod g+rwx "$HOME/.docker" -R
- If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error, which indicates that your ~/.docker/ directory was created with incorrect permissions due to the sudo commands.
-
$ docker run hello-world
Configure Docker to start on boot
Most current Linux distributions (RHEL, CentOS, Fedora, Debian, Ubuntu 16.04 and higher) use systemd to manage which services start when the system boots. On Debian and Ubuntu, the Docker service is configured to start on boot by default. To automatically start Docker and Containerd on boot for other distros, use the commands below:
$ sudo systemctl enable docker.service
$ sudo systemctl enable containerd.service
To disable this behavior, use disable instead.
$ sudo systemctl disable docker.service
$ sudo systemctl disable containerd.service
If you need to add an HTTP Proxy, set a different directory or partition for the Docker runtime files, or make other customizations, see customize your systemd Docker daemon options.
'Docker' 카테고리의 다른 글
도커 - web was 구성 (0) | 2022.04.21 |
---|---|
Docker Compose 네트워크 (0) | 2022.04.21 |
Docker - 네트워크 (0) | 2022.04.21 |
Docker - 파일 저장 위치 (0) | 2022.04.19 |
Install Docker Engine on CentOS (0) | 2022.04.18 |