Install docker and private repository on centos7

Source: Internet
Author: User
Tags docker ps docker hub docker run

Install docker and private repository on centos7
1. initialize the network
After centos7 is installed, yum prompts that the domain name cannot be resolved. view the local network, ifconfig is unavailable, and ip commands in centos7 proxy ifconfig.
Ip addr. Only the local loopback address is displayed.
Cd/etc/sysconfig/network-scripts, View
File corresponding to the NIC name
Onboot is no
Change to yes. After centos is restarted, the network is connected.

2. uname-r check Kernel

3. yum update

4. Add yum Source
Sudo tee/etc/yum. repos. d/docker. repo <-'eof'
[Dockerrepo]
Name = Docker Repository
Base url = https://yum.dockerproject.org/repo/main/centos/7/
Enabled = 1
Gpgcheck = 1
Gpgkey = https://yum.dockerproject.org/gpg
EOF

5. Install
Yum install docker-engine

6. Enable the docker daemon
$ Sudo service docker start
View
Ps-ef | grep dockerd

7. Check whether docker is successfully installed.
Docker run hello-world
The following message indicates that the installation is successful.
Unable to find image 'hello-world: latest 'locally
Latest: Pulling from library/hello-world
C04b14da8d14: Pull complete
Digest: sha256: sha256
Status: Downloaded newer image for hello-world: latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs
Executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
To your terminal.

To try something more ambitious, you can run an Ubuntu container:
$ Docker run-it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
Https://hub.docker.com

For more examples and ideas, visit:
Https://docs.docker.com/engine/userguide/

8. Add to startup Item
Chkconfig docker on

9. Create a docker private server
Docker run-p 5000: 5000 registry

Test:
Download Image
Docker pull ubuntu: 12.04

Run containers
Docker run-I-t ubuntu: 12.04/bin/bash
Modify file content
Root @ ae00895eb68e: cd/home
Echo "print 'test'"> t1.py
Exit

Submit to local
Docker commit-m "add t1.py"-a "lyc" ae00895eb68e ubuntu: 12.04
Tag the image
Docker tag img_id 127.0.0.1: 5000/ubuntu
Submit to private Repository
Docker push 127.0.0.1: 5000/ubuntu
Delete local image
Docker rmi -- force img_id
Download from private Repository
Docker pull 127.0.0.1: 5000/ubuntu
Run containers
Docker run-I-t 127.0.0.1: 5000/ubuntu

View File existence

Export the image to the file Dockersave-o [file_name] [img_id] | [repos_name]
Import the file to the image docker load -- input [img_file]

Shows the relationship between them:

Common commands
Run the docker run-I-t ubuntu container: 12.04/bin/bash
List local image docker images
Show all containers on the local machine docker ps-
Show running container docker ps
Search for docker searchMySQL Images
Delete docker rmi -- force img_id
Export the image to the file docker save-o [file_name] [img_id] | [repos_name]
Import the file to the image docker load -- input [img_file]
View the logs of the specified container docker logs [container_id] or docker logs-f [container_id]
Stop container docker stop [container_id]
Start a stopped container docker start [container_id]
Restart docker restart [container_id]
Container export docker export [container_id]> ubuntu.tar.gz
Delete the container docker rm-f [container_id]
Import the container snapshot to the image cat ubuntu.tar.gz | sudo docker import-[repos_name]
View the docker top [container_id] process in the container
View container details docker inspect [container_id]

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.