How to run Docker containers on CentOS6 or Fedora?

label DockerFedora
3293 people read comment(0) Collection report
Classification:

Tip: 1 in the case of graphics centos6.6 do not upgrade the kernel can be deployed successfully

2 text mode centos6.6 failed, it is estimated that some modules are not

3.failed to find the CGroup root, mountpoint for devices not found errors are because of the absence of any cgconfig operation resulted in, however, need to pay attention to. Cgconfig need to run the service before docker.

      

 

Recently, hot Docker has become a key technology to deploy applications to the cloud environment. Compared with the traditional hardware virtualization technology, based on docker container sandbox for application deployment environment offers a number of advantages, such as light isolation, deployed applications easy to transplant, easy to maintain. Now, the Red Hat Inc is leading the open source community, trying to streamline the management and deployment of Docker container tasks.

Docker is not only applicable to the cloud environment, it is also very useful for end users, if you want to test a certain software in a specific Linux environment, it is even more so. You can easily build a Docker container for the target environment, install and test software in it, and then once you have finished the work, you can throw away the container. The whole process from beginning to end is quite efficient and convenient, and you can always avoid making your terminal system at a mess.

In this tutorial, I will introduce how to create and manage Docker containers on CentOS or Fedora. Please note: at the moment, Docker is supported on 64 host systems. If you want to have a try on Docker Ubuntu, please refer to this tutorial: http://xmodulo.com/manage-linux-containers-docker-ubuntu.html.

Install Docker on CentOS or Fedora

To install the Docker to the CentOS, the EPEL software library is first enabled,

RPM -ivh sudoHttp://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm  

Note: ordinary users access to sudo, modify /etc/sudoers, copy root that line (ALL= ALL (ALL:ALL) root), and then modify

Then use the yum command:

  1. $Yum install docker-io sudo
  2. $service docker start sudo
  3. $chkconfig docker on sudo

To install Docker on the Fedora, use the following commands:

  1. $Yum install docker-io sudo
  2. $systemctl start docker.service sudo
  3. $systemctl enable docker.service sudo

After you install Docker to CentOS or Fedora, you need to add yourself to the docker group, so that you can run the Docker as a non root user. To this end, use this command:

  1. Usermod -a sudo -G docker $USER

Exit, re login to activate group changes.

At this point, you should be able to run the docker command as a non privileged user.

The basic usage of Docker

You want to start a new Docker container, you need to determine which Docker image for the container to use. You can search for the official Docker image index (https://index.docker.io), which lists the publicly available Docker images. Docker index includes: Docker team management Linux basic image (such as Ubuntu, Debian, Fedora and CentOS), as well as the user's contribution to the custom image (such as MySQL, Redis and WordPress).

For example, when you want to open a Ubuntu container in an interactive mode, you have to run the following command. Once the container is started, the final variable "/bin/bash" is executed in the container.

  1. Run -i docker -t Ubuntu /bin/bash

When you first run the command above, it will download the available one or more docker Ubuntu images over the network, and then use the image to start the Docker container. The Ubuntu container will start immediately, you will see the container inside the console prompt. Ubuntu operating system you can access the container inside the sandbox with complete function.

If you type in the prompt exit, will withdraw the containers, the containers will be stopped.

Would like to list all containers (including containers that have been stopped), run the command:

  1. $PS -a docker
  1. ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER
  2. Ubuntu:14.04 /bin/bash About a 6a08a0b2bb4c minute ago Exit 0 cocky_ritchie

Would like to restart in the process of the guardian of a stopped container:

  1. $start [container-id] docker

Would like to remove the container that has been stopped:

  1. $RM [container-id] docker

Would like to connect to a container that runs in the background to see the container or interact with it:

  1. $attach [container-id] docker

You can customize the operation of a container (such as installing new software). If you want to save changes to the content in the current container, you must first exit containers of interactive mode in the prompt type "exit". Then use this command to save the changed image as a different image:

  1. $commit [container-id] [new-image-name] docker

Want to get your container ID, you can use the description of the "PS docker - a" command.

Once you have constructed a new image like this, you can start a new container with the image.

You can also download any open container images (such as bowery/mysql, Ubuntu) and save them to the local library, as shown below.

  1. $pull [image name] docker

Would like to see all the local download / save the container image:

  1. $images docker

You can choose from which specific image to start the container:

  1. Run -i docker -t [image-id] /bin/bash

To remove a container image from a local software library:

  1. $RMI [image-id] docker

englishHttp://xmodulo.com/docker-containers-centos-fedora.html

top
Zero
step on
Zero
Guess you're looking for
View comments
* the above user comments only represent their personal views, does not represent the views or position of the CSDN website
    personal data
    • visit38448 times
    • Integral:One thousand and seventy-four
    • Grade
    • Rank:Thousands of miles away
    • original58
    • Reproduced:106
    • Translation:0
    • Comments:0