Docker local warehouse Simple use of some examples

Source: Internet
Author: User
Tags tag name centos docker ps docker hub docker run

Docker Mirroring Command

Get Mirror: Docker pull CentOS
Viewing mirrors: Docker images
View mirror Details: Docker inspect [Name:tag]
Search Mirrors: Docker search [Name:tag]
Removing mirrors: Docker rmi [Name:tag&id]

-F: Force delete

Create Mirror: Docker commit
Import Mirrors: Cat mirrors. Tar |docker import-centos:7
Save a Mirror: Docker save-o Centos:7.tar Centos7
Load mirror Image: Docker load--imput Cnetos7.tar
Or: Docker load < Centos7.tar
Upload Image: Docker push
Add tags after uploading, as follows:
Docer tag Centos:7 mark/centos:7
Docker Push Mark/centos:7

Docker container Command

New container: Docker create-it Centos:tag
Startup container: Docker start NAME
Create and background start: Docker run--name mynginx-d nginx
-D Daemon Mode

Create a startup and connect the container and start a bash terminal: Docker run-it Mynginx/bin/bash
When Docker run creates and launches a container, Docker runs in the background, including the following:
1, check if the specified mirror exists locally, and does not exist, download from the shared warehouse
2, create and start a container with mirroring
3, allocate a file system, and load a layer of read-write layer on the mirror-only layer
4, from the host configuration of the Network Bridge under the pretext of bridging a virtual excuse to the container
5, assign an IP address from the address pool to the container
6, execute the user-specified application
7, terminate after execution

Where the-t option lets Docker allocate a pseudo terminal and bind to the container's standard output,-I keeps the container's standard input open
Viewing containers: Docker ps-a
Close container: Docker stop NAME

Docker Stop it first sends a sigterm signal to the container, and after a period of time, the default 10 seconds after sending the Sigkill to terminate Rongqi
Startup container: Docker start NAME
Force termination: Docker kill ID
Enter the container to run the command: Docker exec-it Id/bin/bahs
Of course, you can also run the command without entering the container: Docker exec NAME PS

Delete Container: Docker rm ID
To delete a running container: Docker rm-f ID
Exporting containers: Docker export ID > Name.tar
Import container: Cat Name.tar | Docker Import-test/centos:7

To create and use a local private warehouse:

1, download and install registry

We simply build a local private warehouse environment through an official registry image
Docker run-d-P 5000:5000 Registry
This will automatically download and start a registry container, creating a local private warehouse service
By default, the next time you create a/tmp/registry directory in the container, you can use the-v argument to place the mirror on the specified path locally
The following example places the uploaded image in the/opt/registry directory
Docker run-d-P 5000:5000-v/opt/registry:/tmp/registry Registry

[Root@gitlab conf]# Docker Images
REPOSITORY TAG IMAGE ID CREATED SIZE
Registry latest C6C14B3960BD 4 weeks ago 33.28 MB

2, make sure Registry is up state

We can see registry a piece of it being run up to

[Root@gitlab conf]# Docker Ps-a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
29c0811c9195 Registry "/entrypoint.sh/etc/" minutes ago up minutes 0.0.0.0:5000-& Gt;5000/tcp Awesome_wescoff
240c99335256 Marksugar/nginx "/usr/local/nginx/sbi" 2 hours ago up 2 hours 0.0.0.0:81-&gt ; 80/tcp Mynginx
B889bfd7a6ee marksugar/nginx:8.33 "/bin/bash" hours ago up 7 hours 0.0.0.0:80-&gt ; 80/tcp Nginx
[Root@gitlab conf]#

3, Mark and upload the mirror

Use Docker tag to mark a mirror with the following format:
10.10.239.222:5000/alpine, where 10.10.239.222 is the local warehouse address, 5000 is the warehouse port, and Alpine is the mirrored label
The 10.10.239.222 here can be either local IP or domain name, such as: www.111cn.net

[Root@gitlab conf]# docker tag benyoo/alpine:3.4.20160812 10.10.239.222:5000/alpine
When the tag is complete, the local images will have a mirror image of the same as the tag name, and we can upload this image

[Root@gitlab conf]# Docker push 10.10.239.222:5000/alpine
The push refers to a repository [10.10.239.222:5000/alpine]
93d40cd73394:pushed
4fe15f8d0ae6:pushed
LATEST:DIGEST:SHA256:41250FEA2BC5DFDC204D54E4D2108AAE7A452876BED359AE277983AEA4AE3E02 size:739
[Root@gitlab conf]#

4, use local warehouse pull

Try a pull just push to the local warehouse mirroring, you will find that the local image faster than the Docker hub much faster

[Root@localhost ~]# Docker Pull 10.10.239.222:5000/alpine
Using default Tag:latest
Latest:pulling from Alpine
Digest:sha256:41250fea2bc5dfdc204d54e4d2108aae7a452876bed359ae277983aea4ae3e02
status:downloaded newer image for 10.10.239.222:5000/alpine:latest
[Root@localhost ~]# Docker Images
REPOSITORY TAG IMAGE ID CREATED SIZE
Marksugar/alpine latest 07a4ff4374e1 hours ago 11.54 MB
Debian latest 031143c1c662 hours ago 125.1 MB
Marksugar/nginx 8.30 e50a274c5823 hours ago 13.77 MB
10.10.239.222:5000/alpine latest 0AE37ED604B2 2 weeks ago 11.54 MB
Benyoo/alpine 3.4.20160812 0ae37ed604b2 2 weeks ago 11.54 MB
Nginx latest 0d409d33b27e 3 months ago 182.7 MB
[Root@localhost ~]#

Error Resolution:

Error response from Daemon:get Https://10.10.239.222:5000/v1/_ping:http:server gave HTTP response to HTTPS client
Only two steps are required:

1,create or Modify/etc/docker/daemon.json

[root@localhost ~]# echo ' {insecure-registries ': [' 10.10.239.222:5000 ']} ' >/etc/docker/daemon.json
[ Root@localhost ~]# Cat/etc/docker/daemon.json
{"insecure-registries": ["10.10.239.222:5000"]}
2, overloading Docker
Root@localhost ~]# systemctl restart Docker

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.