Article directory
- 1. What is Docker?
- 2. Docker download
- 3 some small pits
-
- 3.1 Version number added
- 报错:invoke-rc.d: could not determine current runlevel
- 报错:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- 报错:Unable to find image 'hello-world:latest' locally
- 报错:System has not been booted with systemd as init system (PID 1). Can't operate.
- 4 Reference documents:
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
- Confirm the corresponding version of the operating system.
Check the official website for the Docker version corresponding to the operating system you need.
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
3 some small pits
3.1 Version number added
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 original
It did not meet the requirements of the official website, but was later replaced by
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
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