Centos 6.5 Docker Setup and configuration

Source: Internet
Author: User
Tags docker ps docker hub

• Mirrored Docker Run-i-T Centos/bin/bash is a container that uploads to the official hub is the mirror

• The image is saved in the/var/lib/docker directory

• The image is stored in the warehouse and then downloaded from the warehouse, and the warehouse is stored in registry, the Docker hub

• Process: Download the base image of CentOS (Lite), then add your own content, save it as a new image, run it up

Installing Docker

1. Installing the Epel extension source

RPM-IVH epel-release-6-5.noarch.rpm Vim/etc/yum.repos.d/epel.repo

2. Install and start Docker

Yum-y Install Docker-ioservice Docker start

Configure Docker

1. Get the CentOS base image

Docker Pull CentOS

2. Run the CentOS image

Docker Run-i-T Centos/bin/bash

Creating mirrors

1. Allow Docker to surf the internet

Vim/etc/default/docker "docker_opts="--dns 8.8.8.8--dns 8.8.4.4 "

2. Configure the Yum source

If you do not have a wget command, you need to install Yum

wget <epel address > RPM-IVH epel-release-6-5.noarch.rpm vim/etc/yum.repos.d/epel.repo

3. Exit the image and save

Exit #退出docker Commit < cfe3bf676fe7> <newimage> #保存

3. Create a Dockerfile file

mkdir static_web        #创建存储Dockerfile的目录cd  static_webvim  dockerfile    //Join    FROM          [centos]                       #指定一个基础镜像名称, subsequent operations are based on this image.     maintainer   zhaijunming  [email protected]  # Specify the image's author and contact information     RUN          yum    update                   #更新yum (Each RUN instruction creates a new mirror layer, and if the instruction executes successfully, it commits the mirror layer and then proceeds to the next instruction)    RUN           yum    -y    install  nginx    #安装nginx    run          echo  "Hello nginx"  >/usr/share/nginx/html/index.html    EXPOSE       80                              #应用程序将会使用这个端口. Docker does not automatically open this port for security reasons, you need to specify which port to use when using Docker run

4. Execution of Dockerfile #使用build

CD static_web #进入到Dockerfile所在目录docker build-t= "Jamtur01/httpdimage". #httpdimage是对dockerfile里指定的那个镜像做完操作后, the name of the new image that is saved

# # #Dockerfile执行过程

Docker running a container from the underlying image

• Execute a command to make changes to the container

• Perform a docker commit operation, save, submit a new mirror layer

Docker run a new container based on the mirror that was just submitted

• Execute the next instruction in Docker, knowing that all instructions are executed

-----------------------------------------------------------------

Common Command Collection

Docker version View Docker client, service-side release number, etc.

Docker search <image name> find mirror

Docker pull <image name> download image

Docker push <image name> upload image

Docker image-a List all mirrors

Docker PS display a running container

-A displays all containers, including non-running

-L Displays the last container created, including the one that is not running

Docker logs < container id> list the actions performed in this container

Docker RM < container > Delete this container

Docker RM ' Docker ps-a-l ' Remove all containers

Docker Start/stop/restart < container id> start/stop/restart container

Docker Attach < containers > re-attach to a running container

Docker run-i-T Centos/bin/bash use image to create a container, log in to/bin/bash

-T: Assigning a pseudo-tty to a container

Docker run-i-t-p

Docker build <path> look for a file named Dockerfile under path path, use this configuration to generate a new image file

Docker Build-< <dockerfile> using the specified dockerfile configuration file, Docker gets the content stdin, using this configuration to generate a new image

Docker Port <container> <container port> See which port is mapped to the specified port on the container, in fact Docker PS can also be seen

Docker Commit < container id> < new mirror name >

Docker images View all mirrors


This article is from the "Ming Linux blog" blog, be sure to keep this source http://zhaijunming5.blog.51cto.com/10668883/1696721

Centos 6.5 Docker Setup and configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.