debian9使用国内源安装docker以及一些使用方法 debian9使用国内源安装docker以及一些使用方法

debian9使用国内源安装docker以及一些使用方法

 

首先, 个人环境是debian, 容器是centoshtml

debian

扔源linux

# deb-src [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/debian stretch stable
deb [arch=amd64] http://mirrors.ustc.edu.cn/docker-ce/linux/debian stretch stable  

而后apt update在installdocker

apt-get install docker-ce

开启服务centos

systemctl start docker

而后拉取文件这些不说了bash

docker映射端口和挂载目录ide

				  宿主 容器	   宿主 容器	宿主  容器
docker run -it -p 8083:8080 -p 3389:3306 -v /mnt/:/mnt update /bin/bash

导出容器post

					新名字		容器名字
docker export -o cheng.tar confident_hopper

导入容器测试

						新名字
docker import cheng.tar cheng

下面是镜像问题

(镜像不能重复, 假如是备份原来的镜像cheng, 那么要导入新的镜像update.tar的时候就须要删除现有的cheng镜像, 否则导入失败, 由于当update.tar导入后会变成cheng名字的镜像, 二者名字不能重复, 若是使用export则无此问题)url

导出镜像htm

docker save -o update.tar cheng

导入镜像

docker load -i update.tar

下面有三点须要注意的

1. docker save保存的是镜像(image),docker export保存的是容器(container)。
2. docker load用来载入镜像包,docker import用来载入容器包,但二者都会恢复为镜像。
3. docker load不能对载入的镜像重命名,而docker import能够为镜像指定新名称。

进入容器

					容器名
docker exec -it condescending_franklin /bin/bash

进入容器的方式有4种, 请参考

Docker容器进入的4种方式

下面看下案例

查看端口映射问题

centos

centos我是直接使用rpm包的, 只要两个包

主包: docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm

wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm

依赖: docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm

wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm

安装方式yum, 为何要用yum呢, yum能够解决依赖问题, 安装的时候须要安装noarch先, 由于它会自动搞掂依赖

yum install docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm

yum install docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm

测试

搞掂!

 

做者:chenglee —— 夏天公子 

出处:http://www.cnblogs.com/chenglee/ 

本文版权归做者:chenglee —— 夏天公子 和博客园共有,欢迎转载,但未经做者赞成必须保留此段声明,且在文章页面明显位置给出原文链接,不然保留追究法律责任的权利。

相关文章
相关标签/搜索