Modify the container, and then save the image to the local
$ sudo docker commit-m "Added json gem"-a "Docker Newbee" 0b2616b0e5a8 ouruser/sinatra:v2
4f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c
Where-M to specify the description of the submission, as we use the version Control tool;-A can specify updated user information;
Is the ID of the container used to create the mirror, and finally specifies the warehouse name and tag information for the target image. The ID of this image is returned when the creation is successful
Information.
Docker directory:/var/lib/docker/
Download the image of the library from the public repository and start:
The image file can be stored locally by using the-v parameter.
Specifies the path. For example, the following example places the uploaded image into the/opt/data/registry directory.
$ sudo docker run-d-p 5000:5000-v/opt/data/registry:/tmp/registry Registry
#docker run-d-P 5000:5000--name my_registry-v/home/test/registry:/tmp/registry index.alauda.cn/library/registry
To enter into the container operation:
Docker exec-it Centos_test1/bin/bash
When uploading images from a library to a library, both the library and the remote machine need to modify the Docker boot parameters:
Ubuntu14.0
Vim/etc/default/docker
Add the following line
docker_opts= "$DOCKER _opts--insecure-registry=104.131.173.242:5000"
Restart Docker
sudo service docker restart
#修改docker文件 (centos6.5 version)
Root > Vim/etc/sysconfig/docker
other_args= "--insecure-registry www.monicacca.com:5000"
Docker_cert_path=/etc/docker
#重启docker
Root>sudo Service Docker Restart
Source Document
Source Document
Before entering the library, you need to change the image to the tag identified by the library:
[Email protected]:/home/test# docker tag csphere/centos_snap:7.1 10.1.1.156:5000/csphere/centos_snap:7.1
[Email protected]:/home/test# Docker Images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
Csphere/centos_snap 7.1 9cb1669dff14 hours ago 522.8 MB
10.1.1.156:5000/csphere/centos_snap 7.1 9cb1669dff14 hours ago 522.8 MB
Csphere/ubuntu-new 12.04 3b10b84c7a3c hours ago 201.4 MB
Csphere/centos-new 7.1 1c4100b77d6f hours ago 591.3 MB
csphere/website1 1.0 9e1efed7bd07 hours ago 785.2 MB
Csphere/workpress 4.2 796d351d0b9f hours ago 722.5 MB
Csphere/mysql 5.5 9045193e0fe4 2 days ago 724.9 MB
Index.alauda.cn/lawsonduan/test 5.5 9045193e0fe4 2 days ago 724.9 MB
CSPHERE/PHP-FPM 5.4 Cb02d60727ea 2 days ago 684.9 MB
Csphere/centos 7.1 15e1362ccd01 2 days ago 591.3 MB
Ubuntu 12.04 33eb06bbb379 6 days ago 138.4 MB
Index.alauda.cn/library/registry latest 07d93e41c370 8 weeks ago 422.9 MB
Registry latest 07d93e41c370 8 weeks ago 422.9 MB
CentOS centos7.1.1503 fab4b1df8eb1 5 months ago 212.1 MB
Passing an image into a private library
Docker Push 10.1.1.156:5000/csphere/centos_snap
To view the library:
Curl Http://10.1.1.156:5000/v1/search
Create a data container to share the same data storage directory with other containers, and the data container does not need to be run:
# docker run-d-v/dbdata--name dbdata csphere/centos:7.1 echo "Data-only container"
#docker run-d--volumes-from dbdata--name centos_db1 csphere/centos:7.1
Docker run-d--volumes-from dbdata--name centos_db2 csphere/centos:7.1
To view the logs for a container:
#docker logs-f CENTOS_DB1
Container interconnection:
#docker run-d--name db1 csphere/mysql:5.5
#docker run-d-P--name web2--link db1:db1 csphere/php-fpm:5.4 (previous DB1 is the database container name, followed by an alias)
#docker exec-it Web2/bin/bash
[Email protected]/]# more/etc/hosts
172.17.0.12c209d4c8b215
127.0.0.1localhost
:: 1localhost ip6-localhost ip6-loopback
fe00::0ip6-localnet
ff00::0Ip6-mcastprefix
Ff02::1Ip6-allnodes
Ff02::2ip6-allrouters
172.17.0.11db1 4b490b7dcde9
[[email protected]/]# Ping db1
PING db1 (172.17.0.11) bytes of data.
Bytes from DB1 (172.17.0.11): icmp_seq=1 ttl=64 time=2.28 ms
Bytes from DB1 (172.17.0.11): icmp_seq=2 ttl=64 time=0.122 ms
Bytes from DB1 (172.17.0.11): icmp_seq=3 ttl=64 time=0.124 ms
Multiple web containers can link to a DB container
After the Mount host already exists the directory, in the container to operate it, reported "Permission denied".
There are two ways to solve this:
1> off SELinux.
Temporary close: # Setenforce 0
Permanently closed: Modify the/etc/sysconfig/selinux file to set the SELinux value to disabled.
2> to start a container in a privileged manner
Specifying the--privileged parameter
such as: # Docker run-it--privileged-v/test:/soft Centos/bin/bash
This article is from the "old section of the Cultivation of Life" blog, please be sure to keep this source http://031028.blog.51cto.com/9866455/1837207
Docker Common Commands