Docker Beginner Notes

Source: Internet
Author: User

What is Docker

Not exactly, Docker is a lightweight virtual machine that packs executables and run environments into an image that runs in a container, but starts faster than a virtual machine and consumes less resources. This technique is primarily intended to address the issue of deployment environments.

Get image from remote repository
docker pull <image:[tag]>

An image of the same name can be tagged to differentiate the version. If you do not add tag, the default is latest

Container operation

Create container

docker run [options] <image> <cmd>
    • -d daemon mode, running in the background
    • --name set the name. It is better to set one, or in the stop, RM time to access through the ID, trouble
    • --net networking mode, see after.
    • --RM is deleted after container exits. Otherwise, the container will still exist in the "exited" state.

Container's name cannot be repeated.

Stop, start (only temporarily stop, not delete, can continue to run)

docker stop|start <container_id|container_name>

Delete

docker rm [-f] <container_id|container_name>

If you set a name when creating a container, you can access it by name and Support tab completion.

Show process

Docker's container does not automatically delete after exiting, but still exists in a stopped manner.

docker ps [options]
    • -a displays all container. Otherwise, only the running container is displayed by default
    • -Q displays only the ID. Otherwise the default display ID, name, corresponding image, startup time and other information
Clear

Docker does not have commands like clean, you can delete all container by itself.

docker rm -f $(docker ps -aq)

Delete all image

docker rmi $(docker images -q)
Networking mode

Docker supports multiple networking modes between host and container, one is the default mode, with Ifconfig you can see one more network interface, container open port is not accessible through the host IP. The other is the host mode (using the parameter--net=host), in this mode, container directly using the host's network stack, the port directly through the host external exposure.

Docker Beginner Notes

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.