docker运维

编辑 /etc/docker/daemon.json文件
[root@centos238 download]# vi  /etc/docker/daemon.json
[root@centos238 download]# systemctl restart docker.service
[root@centos238 download]# cat   /etc/docker/daemon.json
{
}

启动docker
[root@centos238 download]# systemctl restart docker.service

查看docker的状态
[root@centos238 download]# systemctl status  docker.service
[root@centos238 download]# 

确认docker是否安装
[root@centos71 ~]# rpm -qa|grep docker
docker-client-1.13.1-91.git07f3374.el7.centos.x86_64
docker-common-1.13.1-91.git07f3374.el7.centos.x86_64
docker-1.13.1-91.git07f3374.el7.centos.x86_64

拉取镜像并save
[root@centos71 ~]# docker pull docker.io/rancher/server
[root@centos71 ~]# docker save docker.io/rancher/server:latest >/tmp/download/rancherimage.tar

传到跳板机
[root@centos71 download]# scp /tmp/download/rancherimage.tar  root@172.20.70.240:/tmp/download/
root@172.20.70.240's password: 
rancherimage.tar                                                                                                           100% 1056MB  26.7MB/s   00:39    
[root@centos71 download]# 

从跳板机器拷贝到目标机
[root@sshbridge download]# scp rancherimage.tar centos238:/tmp/download/
rancherimage.tar                                                                                100% 1056MB  27.7MB/s   00:38    
[root@sshbridge download]# 

目标机load镜像
[root@centos238 download]# ll
total 1081028
-rw-r--r-- 1 root root 1106971136 Feb 26 01:48 rancherimage.tar
[root@centos238 download]# docker load < rancherimage.tar 
确认镜像
[root@centos238 download]# docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
docker.io/rancher/server   latest              aff17b0067db        3 weeks ago         1.09 GB
[root@centos238 download]# 

docker 启动rancher镜像

[root@centos238 download]# docker run -d --restart always --name rancher-server -p 8080:8080 docker.io/rancher/server:latest && docker logs -f rancher-server

访问rancher http://192.168.56.238:8080/

 

配置本地私有镜像库

1.首先下载registry或者load镜像
docker load < registryimage.tar 
docker images
2.启动registry镜像的容器
docker run -d -p 5000:5000 -v /myregistry:/var/lib/registry docker.io/registry:latest
说明:
-d ==> 作为daemon进程启动,也就是后台启动
-v /myregistry:/tmp/registry ==> 默认情况下,会将仓库存放于容器内的/tmp/registry目录下,指定本地目录/myregistry挂载到容器,可以防止容器意外停止后镜像的丢失。/var/lib/registry为容器内的路径
-p 5000:5000 ==> 前一个5000是host的端口,后一个是容器的端口。这里是将容器的5000端口映射到host的5000端口。
3.确认目录
ls /myregistry
4.确认进程
docker ps

 

补充:

[root@centos238 myregistry]# docker ps
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS                              NAMES
88affd595e08        docker.io/registry:latest         "/entrypoint.sh /e..."   6 minutes ago       Up 6 minutes        0.0.0.0:5000->5000/tcp             jovial_liskov
c87a3d548e64        docker.io/rancher/server:latest   "/usr/bin/entry /u..."   About an hour ago   Up About an hour    3306/tcp, 0.0.0.0:8080->8080/tcp   rancher-server
[root@centos238 myregistry]# docker exec -it 88affd595e08 bash
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"bash\": executable file not found in $PATH"
[root@centos238 myregistry]# docker exec -it 88affd595e08 sh
/ # ls /var/lib/registry
/ # cd /var/lib/registry
/var/lib/registry # pwd
/var/lib/registry
/var/lib/registry # cd ..
/var/lib # ls -l
total 0
drwxr-xr-x    2 root     root             6 Jan 30 02:55 apk
drwxr-xr-x    2 root     root             6 Jan 30 02:55 misc
drwxr-xr-x    2 root     root             6 Feb 26 08:14 registry
drwxr-xr-x    2 root     root             6 Jan 30 02:55 udhcpd
/var/lib # date
Tue Feb 26 08:22:14 UTC 2019
/var/lib # exit

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值