ubuntu基礎鏡像安裝

1. 下載ubuntu模板

這里以ubuntu14.04 為例,從openvz下載一個ubuntu14.04的模板
wget http://download.openvz.org/template/precreated/ubuntu-14.04-x86_64.tar.gz

2. 從本地鏡像import鏡像

cat ubuntu-15.10-x86_64-minimal.tar.gz |docker import - ubuntu:base

  • 或者

  • 使用國內(nèi)的 daocloud 的倉庫

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://cb340bea.m.daocloud.io

3. 進入虛擬機

docker run -t -i ubuntu:latest /bin/bash

3.1 更新

apt-get update

3.2 安裝supervisor服務

apt-get install supervisor cd /etc/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 在執(zhí)行的時候會直接退出)
    [include]
    files = /etc/supervisor/conf.d/*.conf
    
    [program:sshd]
    command = /usr/sbin/sshd -D        ;(添加ssh服務)
    

3.3 配置ssh服務

  • 創(chuàng)建ssh的運行目錄

mkdir /var/run/sshd

  • 更改root密碼 passwd

passwd 123456

  • 允許root登陸

vi /etc/ssh/sshd_config 修改下面2個參數(shù)允許
[沒安裝ssh的話先安裝:apt-get install openssh-server]
PermitRootLogin yes UsePAM no

3.4退出docker

exit

3.5 commit最新的Ubuntu:base

docker commit f3c8 ubuntu:base

3.5 根據(jù)Dockerfile開放22端口

  • 新建一個目錄

mkdir ubuntu touch ubuntu/Dockerfile vi ubuntu/Dockerfile

  • 添加如下內(nèi)容

FROM ubuntu:base EXPOSE 22 CMD ["/usr/bin/supervisord"]

  • 然后從這個文件創(chuàng)建image

docker build -t ubuntu:base ubuntu/

3.6 運行基礎鏡像

docker run -p 301:22 -d --name test ubuntu:base /usr/bin/supervisord
ssh 到301端口
ssh root@192.168.99.100 -p 301

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容