http://wiki.jikexueyuan.com/project/docker/userguide/dockerhub.html
http://www.voidcn.com/article/p-dkzovvph-bhg.html
官网资料 :https://docs.docker.com/get-started/
再Ubuntu下安装Docker完成后,操作:
dockers --version
ubuntu@VM-0-13-ubuntu:~$ docker --version
Docker version 18.09.2, build 6247962
”Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.26/images/json: dial unix /var/run/docker.sock: connect: permission denied“
解决方法:将当前用户加入安装中自动创建的docker用户组
sudo usermod -aG docker 此处为自己的用户名
重新链接即可。
docker pull ubuntu:18.04
完整命令 格式:docker [image] pull NAME:[:TAG]
(名称+标签)
不指定标签 TAG ,则使用最新的版本镜像。
如果从非官方仓库下载,需要指出下载仓库的完整地址:
docker iamges
ubuntu@VM-0-13-ubuntu:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 94e814e2efa8 2 days ago 88.9MB
仓库镜像 标签 ID 镜像最后更新的时间
ubuntu@VM-0-13-ubuntu:~$ docker run -it ubuntu:18.04 bash
root@c0dbec1ccba7:/# echo "Hello World"
Hello World
root@c0dbec1ccba7:/# exit 退出
exit
docker tag ubuntu:18.04 haha-xiaofeixia:000
ubuntu@VM-0-13-ubuntu:~$ docker tag ubuntu:18.04 haha-xiaofeixia:000
ubuntu@VM-0-13-ubuntu:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
haha-xiaofeixia 000 94e814e2efa8 2 days ago 88.9MB 新命名的小飞侠
ubuntu 18.04 94e814e2efa8 2 days ago 88.9MB
添加标签是添加一个类似链接作用的别名。
使用 docker rmi 或者 docker image rm 命令
ubuntu@VM-0-13-ubuntu:~$ docker rmi haha-xiaofeixia:000
Untagged: haha-xiaofeixia:000 删除成功
ubuntu@VM-0-13-ubuntu:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 94e814e2efa8 2 days ago 88.9MB
docker rmi + ID
docker image prune
docker search [option] keyword
搜索stars超过4的关键词包含tensorflow的镜像
ubuntu@VM-0-13-ubuntu:~$ docker search --filter=stars=4 tensorflow
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
tensorflow/tensorflow Official Docker images for the machine learn… 1338
jupyter/tensorflow-notebook Jupyter Notebook Scientific Python Stack w/ … 117
xblaster/tensorflow-jupyter Dockerized Jupyter with tensorflow 52 [OK]
tensorflow/serving Official images for TensorFlow Serving (http… 42
rocm/tensorflow Tensorflow with ROCm backend support 19
floydhub/tensorflow tensorflow 17 [OK]
bitnami/tensorflow-serving Bitnami Docker Image for TensorFlow Serving 13 [OK]
opensciencegrid/tensorflow-gpu TensorFlow GPU set up for OSG 8
列出各层的常见信息
docker history ubuntu:18.04
获取镜像的详细信息
docker [image] inspect ubuntu:18.04
参考资料:《Docker 技术入门与实战》第三版
还是看官网上面的教程吧,官网上面的最佳 https://docs.docker.com/get-started/part2/
参考自官网
li@li-System-Product-Name:~$ sudo apt-get update
li@li-System-Product-Name:~$ sudo apt-get install \
> apt-transport-https \
> ca-certificates \
> curl \
> gnupg-agent \
> software-properties-common
li@li-System-Product-Name:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
li@li-System-Product-Name:~$ 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)
sub rsa4096 2017-02-22 [S]
li@li-System-Product-Name:~$ sudo add-apt-repository \
> "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) \
> stable"
li@li-System-Product-Name:~$ sudo apt-get update
li@li-System-Product-Name:~$ sudo apt-get install docker-ce docker-ce-cli containerd.io
测试
li@li-System-Product-Name:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Already exists
Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
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/