Installation of docker environment

1. Environment configuration (linux)

1. The requirement for docker to run on Centos7.x is that the kernel version is above 3.10. Check the kernel version:

uname -r

 2. Update the index of the yum package

sudo yum makecache fast

sudo yum install epel-release

 

 2. Installation method

1. Official one-click installation method

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

2. Dockers start

1.1 Start docker command: sudo systemctl start docker

1.2 Verify whether docker is installed correctly

  sudo docker pull hello-world

  sudo docker run hello-world

1.3 View all containers under docker

  docker ps -a all containers; docker ps all running containers

1.4 Common commands

Set up auto-start at boot: chkconfig docker on

Daemon restart: systemctl daemon-reload

Restart the docker service: systemctl restart docker / service docker restart

Shut down the docker service: docker systemctl stop docker / docker service docker stop

Remove docker: yum remove docker-ce

Delete images, containers, configuration files, etc.: rm -rf /var/lib/docker

Search the warehouse image: docker search image name

Pull the image: docker pull image name

Delete container: docker rm container ID

View images: docker images

Delete image: docker rmi image ID

Start and stop the container: docker start/stop container ID/name

Enter the container: docker exex -it container name, ID /bin/bash

Configure the docker mirror address: echo "OPTIONS='--registry-mirror=https://mirror.ccs.tencentyun.com'" >> /etc/sysconfig/docker After execution (systemctl daemon-reload, service docker start)

3. Install docker on Ubuntu20.04

1. Install curl: sudo apt install curl

2. Add docker’s official GPG key: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

3. Add docker package source: sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

4. Update the package cache and install docker: sudo apt update sudo apt install docker-ce

5. Verify whether it is successful: docker version

6. By default, only the root user or users in the sudoer list can run Docker commands, while ordinary users need to execute Docker commands through sudo. To avoid having to enter a password every time you run a Docker command, you can add the current user to the docker user group: sudo usermod -aG docker $USER

7. In order for the modification of the user group to take effect, you need to restart the Docker service: sudo systemctl restart docker

Guess you like

Origin blog.csdn.net/weixin_38863607/article/details/130284829