Docker--1. First introduction to Docker installation and pitfalls

1. What is Docker?

Docker allows developers to package their applications and dependencies into a lightweight, portable container, and then publish it to any popular Linux machine , which can also be virtualized.


2. Docker download

2.1 Confirm version

  1. Confirm the corresponding version of the operating system.
    Check the official website for the Docker version corresponding to the operating system you need.

Insert image description here
2. Confirm that your operating system version meets the version number required by docker. For example: the versions required in Ubuntu are the following ones

Insert image description here


3 some small pits

3.1 Version number added

Insert image description here
Contain <> for replacement. for example:

sudo apt-get install docker-ce=5:20.10.17~3-0~ubuntu-focal docker-ce-cli=5:20.10.17~3-0~ubuntu-focal containerd.io docker-compose-plugin

报错:invoke-rc.d: could not determine current runlevel

Error reporting location

sudo apt-get install docker-ce=5:20.10.17~3-0~ubuntu-focal docker-ce-cli=5:20.10.17~3-0~ubuntu-focal containerd.io docker-compose-plugin

solution

Check whether your OS and version meet the requirements in the official documentation. If not, change the OS.

The author's originalInsert image description here

It did not meet the requirements of the official website, but was later replaced by Insert image description here
a successful download.

报错:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Error reporting location

An error occurs when running the following code

 sudo docker run hello-world

solution

Let’s look at the installation first

docker version

result
Insert image description here

Error message prompts:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

It turns out that it is not running, docker startup command

sudo service docker start 	#命令行
 * Starting Docker: docker  #提示信息

报错:Unable to find image ‘hello-world:latest’ locally

Error reporting location

Run the command again:

sudo docker run hello-world

Pop-up message:

Unable to find image ‘hello-world:latest’ locally
docker: Error response from daemon: Head “https://registry-1.docker.io/v2/library/hello-world/manifests/latest”: net/http: TLS handshake timeout.
See ‘docker run --help’.

It probably means that the hello-world image cannot be pulled during runtime and an error is reported.

solution

Add new image

sudo vim /etc/docker/daemon.json

Newly added text content

{ 
 "registry-mirrors": ["https://alzgoonw.mirror.aliyuncs.com"] 
 }

Restart docker

sudo service docker restart #Windows下WSL2子系统运行命令
#或者Linux下命令
systemctl restart docker

Re-execute the command

sudo docker run hello-world

报错:System has not been booted with systemd as init system (PID 1). Can’t operate.

Error reporting location

在Windows下wsl2使用Linux子系统中调用了 systemctl  命令

solution

应该使用 service 命令

4 Reference documents:

4.1 Docker installation pitfalls

Please contact the author for infringement or deletion

Guess you like

Origin blog.csdn.net/Srwici/article/details/125516116