Docker-创建本地的镜像和上传下载镜像
2017-07-04 09:45
756 查看
Docker构建本地镜像
创建文件
2.编辑文件
3.Dockerfile构建镜像
4.运行自己的镜像docker-whale
此处可能出现构建本地镜像错误的问题:原因是镜像源可能出现错误,最好使用官方的镜像源
二.Docker push镜像到docker hub并验证
tag/push/pull 镜像
1.查看镜像
2.寻找镜像ID
3.使用docker login远程登录到docker hub
4.使用push命令上传镜像
确定名字空间
dockerhub帐号/镜像名:shursulei/hello-world
使用image id 和docker tag标记镜像
再次查看镜像
最后使用Push上传到自己的hub的仓库中
三.Docker从docker hub pull镜像到本地
1.查看本地镜像
2.查看帮助
2.删除本地的镜像文件
3.使用docker run下载镜像并使用
创建文件
sulei@sulei:~$ cd docker bash: cd: docker: 没有那个文件或目录 sulei@sulei:~$ mkdir mydocker sulei@sulei:~$ cd mydocker/ sulei@sulei:~/mydocker$ ls sulei@sulei:~/mydocker$ touch Dockerfile
2.编辑文件
FROM docker/whalesay:latest RUN apt-get -y update && apt-get install -y fortunes CMD /usr/games/fortune -a |cowsay #添加fortunes程序到镜像中
3.Dockerfile构建镜像
sulei@sulei:~/mydocker$ sudo docker build -t docker-whale . ---> Running in 0eaf8a62140a ---> 6b7de031519f Removing intermediate container 0eaf8a62140a Successfully built 6b7de031519f
4.运行自己的镜像docker-whale
sulei@sulei:~/mydocker$ sudo docker images#查看自己的镜像 #运行自己的镜像文件 sulei@sulei:~/mydocker$ sudo docker run docker-whale ______________________________________ / But, officer, he's not drunk, I just \ \ saw his fingers twitch! / -------------------------------------- \ \ \ ## . ## ## ## == ## ## ## ## === /""""""""""""""""___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\______/
此处可能出现构建本地镜像错误的问题:原因是镜像源可能出现错误,最好使用官方的镜像源
二.Docker push镜像到docker hub并验证
tag/push/pull 镜像
1.查看镜像
2.寻找镜像ID
3.使用docker login远程登录到docker hub
sudo docker login --username=yourhubusername --email=youremail@company.com sulei@sulei:~/mydocker$ sudo docker login --username=shursulei --email=1368455669@qq.com Flag --email has been deprecated, will be removed in 17.06. Password: Login Succeeded
4.使用push命令上传镜像
确定名字空间
dockerhub帐号/镜像名:shursulei/hello-world
使用image id 和docker tag标记镜像
docker tag 7694d52625 maryatdocker/docker-whale:latest //例子 sulei@sulei:~/mydocker$ sudo docker tag 1815c82652c0 shursulei/hello-world:latest
再次查看镜像
sulei@sulei:~/mydocker$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker-whale latest 6b7de031519f 36 minutes ago 275MB hello-world latest 1815c82652c0 2 weeks ago 1.84kB shursulei/hello-world latest 1815c82652c0 2 weeks ago 1.84kB docker/whalesay latest 6b362a9f73eb 2 years ago 247MB sulei@sulei:~/mydocker$
最后使用Push上传到自己的hub的仓库中
sulei@sulei:~/mydocker$ sudo docker push shursulei/hello-world The push refers to a repository [docker.io/shursulei/hello-world] 45761469c965: Mounted from library/hello-world latest: digest: sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f size: 524
三.Docker从docker hub pull镜像到本地
1.查看本地镜像
sulei@sulei:~/mydocker$ sudo docker images
2.查看帮助
sudo docker rm Remove one or more containers rmi Remove one or more images
2.删除本地的镜像文件
sulei@sulei:~/mydocker$ sudo docker rmi -f 1815c82652c0 Untagged: hello-world:latest Untagged: hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f Untagged: shursulei/hello-world:latest Untagged: shursulei/hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f Deleted: sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57 #也可以用使用仓库名删除
3.使用docker run下载镜像并使用
sulei@sulei:~/mydocker$ sudo docker run shursulei/hello-world 验证是否成功 sulei@sulei:~/mydocker$ sudo docker images
相关文章推荐
- 本地Docker镜像的上传与下载
- 【Docker】创建私有仓库, 查看私有仓库镜像, 方便本地共享
- docker 创建本地镜像服务器
- docker学习-进入的container及创建本地镜像
- 不通过docker registry共享下载的image(docker镜像本地迁移)
- 配置 Docker 镜像下载的本地 mirror 服务
- php操作ftp上传文件、创建目录、删除文件、删除目录、下载文件到本地
- Docker创建一个mysql容器并保存为本地镜像
- Docker-创建一个mysql容器,并保存为本地镜像
- 标记,上传并下载自己创建的镜像 image
- docker学习笔记5:利用commit命令创建镜像 和 删除本地镜像
- docker 创建本地镜像服务器
- docker无法上传镜像到本地仓库
- php操作ftp上传文件、创建目录、删除文件、删除目录、下载文件到本地
- docker基于本地模版导入创建镜像
- 配置 Docker 镜像下载的本地 mirror 服务
- docker创建镜像并上传dockerhub
- docker官方镜像下载及使用Dockerfile创建镜像的方法
- 3.搭建docker私有仓库,并上传下载镜像
- Docker学习笔记(三)- Dockerfile创建本地镜像