Three major docker components: container and docker

Source: Internet
Author: User
Tags docker stop container docker ps docker run

Three major docker components: container and docker
1. containers are another core concept of Docker.

Simply put, containers are one or more applications that run independently and Their runtime environments. The virtual machine can be understood as a simulation.
A complete set of operating systems (including the running environment and other system environments) and applications running on them.

1.1 start container 1.1.1 and docker run
[root@bfd-v7 ~]# docker run ubuntu:12.04 /bin/echo 'Hello docker'Hello docker

When docker run is used to create a container, the standard operations that Docker runs in the background include:

Check whether a specified image exists locally. If the image does not exist, download the image from the public warehouse and create a container to allocate a file system, the read-only image layer is mounted to the read/write layer to bridge a virtual interface from the bridge interface configured by the host to the container to configure an ip address from the address pool for the container. after the application is executed, the container is terminated 1.1.2, And the docker startdocker ps-a container is started to view all containers including stopped containers. Docker start id

1.2 daemon running

Docker containers run in Daemonized mode in the background. In this case, you can add the-d Parameter
Number.

[root@bfd-v7 ~]# docker run -d ubuntu:12.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"

You can view the docker logs container id as follows:

1.3 docker stop container id
[Root @ bfd-v7 ~] # Docker stop container id

To restart a container in the terminated state, run the docker start command.

1.4 enter the container attach
[Root @ bfd-v7 ~] # Docker run-idt ubuntu: 12.04 [root @ bfd-v7 ~] # Docker attach container id # exit container [root @ bfd-v7 ~] # Exit

1.5 export and Import of containers 1.5.1 and export docker export commands
[root@bfd-v7 container]# docker ps[root@bfd-v7 container]# docker export fb8a9e65bc79 > wyl-nginx.tar

1.5.2 import docker import command
# V1 is a tag sign [root @ bfd-v7 container] # docker import wyl-nginx.tar wyl-nginx: v1 # returns an idsha256: container


Note: You can use docker load to import the image storage file to the local image repository, or use docker import to import a container snapshot to the local image repository. The difference between the two is that the container snapshot file will discard all historical records and metadata (that is, only save the current snapshot status of the container), and the image storage file will save the complete record, the volume is also large. In addition, you can re-specify tag and other metadata information when importing from the container snapshot file.

1.6 Delete the container rm command

You can use docker rm to delete a terminated container. to delete a running container, you can add the-f parameter. Docker sends a SIGKILL signal to the container.

# Delete a stopped container, first view all containers, select the container id to delete [root @ bfd-v7 container] # docker ps-a [root @ bfd-v7 container] # docker rm 7099f90eb56a

# Delete a running container [root @ bfd-v7 container] # docker rm-f fb8a9e65bc79

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.