标签:docker 修改root密码 docker创建ssh服务
泡了几天官网,对docker有了一点了解。准备着手搭建一个公司的开发测试环境,包括java、python。
首先说明一下我的环境
2台物理服务器(后面简称主机)
主机A的配置如下:
[root@opnvz ~]# lsb_release -a LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Distributor ID: CentOS Description: CentOS release 6.5 (Final) Release: 6.5 Codename: Final [root@opnvz ~]# uname -a Linux opnvz 3.10.52-1.el6.elrepo.x86_64 #1 SMP Fri Aug 8 11:40:18 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux [root@opnvz ~]# docker version Client version: 1.0.0 Client API version: 1.12 Go version (client): go1.2.2 Git commit (client): 63fe64c/1.0.0 Server version: 1.0.0 Server API version: 1.12 Go version (server): go1.2.2 Git commit (server): 63fe64c/1.0.0主机B 今天还用不到,后面再介绍
这里以ubuntu14.04 为例,从openvz下载一个ubuntu14.04的模板
wget http://download.openvz.org/template/precreated/ubuntu-14.04-x86_64.tar.gz
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
apt-get supervisor cp supervisord.conf conf.d/ cd conf.d/ vi supervisord.conf修改该文件如下:
; supervisor config file [unix_http_server] file=/var/run/supervisor.sock ; (the path to the socket file) chmod=0700 ; sockef file mode (default 0700) [supervisord] logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) nodaemon=true ;(修改该软件的启动模式为非daemon,否则docker 在执行的时候会直接退出) [include] files = /etc/supervisor/conf.d/*.conf [program:sshd] command = /usr/sbin/sshd -D ;(添加ssh服务)<span style="font-family:Arial;"><span style="font-size: 14px; line-height: 26px;"> </span></span>
mkdir /var/run/sshd
PermitRootLogin yes
UsePAM no
root@f3c8005aa252:/etc/supervisor/conf.d# exit exit [root@opnvz start]# docker commit f3c8 ubuntu 5c21b6cf7ab3f60693f9b6746a5ec0d173fd484462b2eb0b23ecd2692b1aff6b [root@opnvz start]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest 5c21b6cf7ab3 6 seconds ago 512 MB<span style="font-family:Arial;"><span style="font-size: 14px; line-height: 26px;"> </span></span>
mkdir ubuntu touch ubuntu/Dockerfile vi ubuntu/Dockerfile添加如下内容
FROM ubuntu EXPOSE 22 CMD ["/usr/bin/supervisord"]<span style="font-family:Arial;"><span style="font-size: 14px; line-height: 26px;"> </span></span>
[root@opnvz start]# docker build -t ubuntu ubuntu/ Sending build context to Docker daemon 2.56 kB Sending build context to Docker daemon Step 0 : FROM ubuntu ---> 5c21b6cf7ab3 Step 1 : EXPOSE 22 ---> Running in 00a75d649b65 ---> 0429a60c040d Removing intermediate container 00a75d649b65 Step 2 : CMD ["/usr/bin/supervisord"] ---> Running in 49d505f56418 ---> c5d51fba9226 Removing intermediate container 49d505f56418 Successfully built c5d51fba9226<span style="font-family:Arial;"><span style="font-size: 14px; line-height: 26px;"> </span></span>
[root@opnvz start]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest c5d51fba9226 About a minute ago 512 MB <none> <none> 66604abb62b1 38 minutes ago 570.3 MB<span style="font-family:Arial;"><span style="font-size: 14px; line-height: 26px;"> </span></span>
docker ps -a<span style="font-family:Arial;"><span style="font-size: 14px; line-height: 26px;"> </span></span>找到刚才的容器
docker rm f3c8005aa252
docker rmi 66604abb62b1
[root@opnvz start]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest c5d51fba9226 About a minute ago 512 MB
docker 实战---安装一个基础镜像 (一),布布扣,bubuko.com
标签:docker 修改root密码 docker创建ssh服务
原文地址:http://blog.csdn.net/smallfish1983/article/details/38751019