Docker学习(1)-Dockerfile

来源:互联网 发布:计算机算法 编辑:程序博客网 时间:2024/05/15 15:13
  1. Traning
    1. 去Github搜索Training教程
  2. Docker镜像是分层的(在docker build的过程中能够体现出来)
  3. Registry库 构建自动化平台,持续集成
    1. 更新DockerFile之后docker build自动生成新的Docker Image
    2. 这个就需要借助Git了,有git之后才能说自动化平台
    3. 这就是有持续集成,Jenkins的作用了

生成Docker Image

  1. docker build -t Image_name/Image_version DockerFile_Path
  2. 通过DockerFile生成Docker Image
  3. -t 给Image起一个名字
  4. 命名规则 : registry_url/namespace/Image_password/Image_name:Image_version(也就是Tag,不写的话,默认生成的就是latest)
  5. shell
    Loaded plugins: fastestmirror
    Cleaning repos: base epel extras updates
    Cleaning up everything
    Cleaning up list of fastest mirrors
    ---> 813309c5c189
    Removing intermediate container 458a7d8a9119
    Step 7 : RUN pip install supervisor
    ---> Running in 9d04f00a0723
    /usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
    InsecurePlatformWarning
    You are using pip version 7.1.0, however version 7.1.2 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    Collecting supervisor
    /usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
    InsecurePlatformWarning
    Downloading supervisor-3.1.3.tar.gz (391kB)
    Collecting meld3>=0.6.5 (from supervisor)
    Downloading meld3-1.0.2-py2.py3-none-any.whl
    Installing collected packages: meld3, supervisor
    Running setup.py install for supervisor
    Successfully installed meld3-1.0.2 supervisor-3.1.3
    ---> 15d5fc74da64
    Removing intermediate container 9d04f00a0723
    Step 8 : ADD supervisord.conf /etc/supervisord.conf
    ---> cc30d52cc27a
    Removing intermediate container 0a68ce165085
    Step 9 : RUN mkdir -p /etc/supervisor.conf.d && mkdir -p /var/log/supervisor
    ---> Running in bf31cf925d62
    ---> 1f8441516965
    Removing intermediate container bf31cf925d62
    Step 10 : EXPOSE 22
    ---> Running in def88536757d
    ---> 0d82c89bc153
    Removing intermediate container def88536757d
    Step 11 : ENTRYPOINT /usr/bin/supervisord -n -c /etc/supervisord.conf
    ---> Running in 0ed8448107f7
    ---> 6cc4c6a7ee5d
    Removing intermediate container 0ed8448107f7
    Successfully built 6cc4c6a7ee5d

根据Docker Image 运行 Container

sudo docker run -d -p 2222:22 —–name centos_base centos_liuyanshi:latest

  1. docker run -it(以交互模式运行)/-d(后台模式运行,返回一个Container ID)
    1. -P / -p端口映射
    2. docker run -d -P 22 宿主机的随机分配的端口和Container的22端口进行映射 EXPOSE 22
    3. docker run -d -p 2222:22 宿主机的2222端口和Container的22端口进行映射
  2. 基础镜像

2015年10月17日23:39:55 -Step1


0 0
原创粉丝点击