docker 草稿


 1. 从文件系统导入
目前可用的文件系统主要是openvz的模板
比如:下载了一个ubuntu14.04的镜像 cat ubuntu-14.04-x86_64-minimal.tar.gz |docker import - ubuntu:14.04 然后用docker images看下:

sudo docker pull dl.dockerpool.com:5000/ubuntu:14.04
sudo docker tag dl.dockerpool.com:5000/ubuntu:14.04 jw:1
sudo docker run -i -t jw:1 /bin/bash
    
vi /etc/apt/sources.list
dd all
past next
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 update

apt-get install wget
apt-get install --fix-missing wget
exit

sudo docker commit 4eb6  jw:2
sudo docker images
js:2 228.4MB


sudo docker run -i -t jw:2 /bin/bash

cd /usr/local/tmp

wget http://192.168.10.188:8083/apache-tomcat-8.0.26.tar.gz
wget http://192.168.10.188:8083/jdk-7u75-linux-x64.tar.gz

cd /usr/local
tar -zxvf tmp/jdk-7u75-linux-x64.tar.gz -C .
tar -zxvf tmp/apache-tomcat-8.0.26.tar.gz -C .

mv jdk1.7.0_75/ jdk7
mv apache-tomcat-8.0.26/  tomcat8
rm -R tmp

du -sh .
JDk7 285MB

sudo docker commit 8e21  jw:3   已经有了基本的jdk和tomcat软件了
sudo docker run -i -t jw:3 /bin/bash

sudo docker info
sudo docker images  
 
Dockerfile
# Pull base image  
FROM jw:3
 
MAINTAINER Ken "[email protected]"  
 
#setting
ENV JAVA_HOME /usr/local/jdk7/
ENV JRE_HOME /usr/local/jdk7/jre/
ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib
ENV CATALINA_HOME /usr/local/tomcat8  
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
# Expose ports.  
EXPOSE 8080  


CMD /usr/local/tomcat8/bin/catalina.sh run


sudo docker build -t jv:301 .


docker run -d -p 22 -p 8081:8080 jv:301
http://192.168.10.200:8081/
tomcat 页面,Done


docker images 占满了硬盘空间, 清理冗余的image
rm Remove one or more containers
rmi Remove one or more images
    1.进入root权限
    sudo su
    # docker stop $(docker ps -a -q)
    列出container
    docker ps -a
    CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
    eff80d15c2b3        deebc4b899b9        /bin/sh -c '/usr/loc   About an hour ago                                           pensive_jones
    删除 container
    root@localhost :/home/ken/docker# docker rm eff
    eff
    root@localhost :/home/ken/docker# docker ps -a
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    root@localhost :/home/ken/docker# docker images
    REPOSITORY                      TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    <none>                          <none>              46090bfd8262        44 minutes ago      533.6 MB
    jw                              3                   008a4dee0cb1        About an hour ago   533.6 MB
    jw                              2                   8b38303c6d8c        About an hour ago   228.4 MB
    <none>                          <none>              e04b4e186782        About an hour ago   684.8 MB
    dl.dockerpool.com:5000/ubuntu   14.04               5506de2b643b        10 months ago       199.3 MB
    ubuntu                          14.04               5506de2b643b        10 months ago       199.3 MB
    jw                              1                   5506de2b643b        10 months ago       199.3 MB
    root@localhost :/home/ken/docker# docker rmi 460
    Deleted: 46090bfd82624dc7a382accf986c24d94d227e1dd36551d8aae5d3d3f8c8f3ec
    Deleted: f74a0ae662016c15f07b2a5a357072aa5c6dabcf39b1df6a7b1078b612a1b6f1
    Deleted: 467a400479aa027c60e110144a7f7d3f61207bddff2cc8bfdea4068afc85f97d
    Deleted: bb1ff842df88e98d9b001890240ad7453ff6257e97b4cc9d24a88436a43eef9e
    Deleted: 62236a6e6cc5af6fc7e9f6940f8a432625524c5898680c08c4f8b206bf817246
    Deleted: 56cbf21280097ee58f8f9081db7cb427c0bc7101470774ee04d03ac06aaaa622
    root@localhost:/home/ken/docker# docker images
    REPOSITORY                      TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    jw                              3                   008a4dee0cb1        About an hour ago   533.6 MB
    jw                              2                   8b38303c6d8c        About an hour ago   228.4 MB
    <none>                          <none>              e04b4e186782        About an hour ago   684.8 MB
    dl.dockerpool.com:5000/ubuntu   14.04               5506de2b643b        10 months ago       199.3 MB
    ubuntu                          14.04               5506de2b643b        10 months ago       199.3 MB
    jw                              1                   5506de2b643b        10 months ago       199.3 MB

你可能感兴趣的:(docker 草稿)