大家好,又见面了,我是你们的朋友全栈君。
sudo apt-get remove docker docker-ce
whereis docker
结果如下:
docker: /usr/bin/docker /etc/docker /usr/libexec/docker /usr/share/man/man1/docker.1.gz
使用rm -rf
命令删除这些文件
如:
sudo rm -rf /usr/bin/docker
删除后,可以使用docker
或which
命令
dream@dream-PC:~$ docker
bash: docker: 未找到命令
dream@dream-PC:~$ which docker
dream@dream-PC:~$
可以看到docker已被卸载
dream@dream-PC:~$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
OK
dream@dream-PC:~$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian wheezy stable"
上面命令中wheezy为debian版本号的代号,可通过cat /etc/debian_version
查看版本,对应代号关系如下:
deepin15.5 ==> debian8.0 ==> jessie
deepin15.9.2 ==> debian9.0 ==> stretch
deepin20 ==> debian10 ==> buster
这里会报错,但不会影响docker正常安装
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Deepin/camel
docker-ce
sudo apt-get install docker-ce
dream@dream-PC:~$ docker version
Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:45:52 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:44:23 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
dream@dream-PC:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:d58e752213a51785838f9eed2b7a498ffa1cb3aa7f946dda11af39286c3db9a9
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
可以看到15行,显示docker可以正常运行了。
由于系统盘容量较小,所以想将docker的相关文件移动到数据盘。
修改/etc/docker/daemon.json
若没有daemon.json文件,使用以下命令可自动创建
dream@dream-PC:~$ sudo vim /etc/docker/daemon.json
在该文件中写入以下数据
{
"data-root": "/home/dream/docker"
}
目录可以自定义
重启docker
systemctl restart docker
查看该目录,可以看到相关文件
dream@dream-PC:~$ cd /home/dream/docker/
dream@dream-PC:~/docker$ ls
builder containers network plugins swarm trust
buildkit image overlay2 runtimes tmp volumes
dream@dream-PC:~/docker$
还是修改daemon.json
文件
在文件中加入镜像源地址,daemon.json
内容如下:
{
"data-root": "/home/dream/docker",
"registry-mirrors": ["http://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"http://docker.mirrors.ustc.edu.cn"]
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/196169.html原文链接:https://javaforall.cn