Docker installation and basic command __docker

Source: Internet
Author: User
Tags docker stop container docker ps docker run
installation and basic commands for Docker first, the installation of Docker

Here only the CentOS system installation docker, operating system kernel version requirements above 3.10 and must be 64 bits, generally centos 6.5 or above, if not sure, you can view the kernel version, typing command

Uname-r

Yum installation Command

Yum-y Install Docker
Install the specified version

View all Versions

Yum List Docker

Install the version, for example:

Yum-y Install docker-1.12.6

Second, Docker basic command Start Docker
Systemctl Start Docker

Or

Service Docker start
View Docker version number
Docker version


Docker run a Hello-world
Docker Run Hello-world

unload Docker, leaving data such as mirrors, volumes, containers, etc.

Yum-y Remove Docker
delete containers, mirrors, volumes, and custom configuration files
Rm-rf/var/lib/docker
Searching for mirrors, for example, searching for a nginx mirror
Docker Search Nginx

The table has five columns, meaning the following:

Nane: Mirrored warehouse Name

DESCRIPTION: Mirrored Warehouse Description

STATUS: Mirrored warehouse collection, which is how many times it was collected, indirectly indicates the degree of popularity of the warehouse

Offical: Identification is the official warehouse, OK is identified by the software's official project team to create and maintain

Automated: Identifies whether it is an automatically built mirrored warehouse


Download Mirror:

For example, to download a nginx

Docker Pull Nginx

At this point, a nginx mirror that defaults to the latest version is downloaded

If you want to download a specific version of the mirror, you need to search on the Dockerhub


And then download the version that you specified

Docker Pull nginx:1.12.2

View all mirrors on this computer

Docker images

The figure above is a mirror of my own creation, this figure is for reference only, here are five columns, respectively identifying

REPOSITORY: Mirrors the owning warehouse

Tag: Mirrored label, also can be said to be version

Image ID: Mirror ID, uniquely identifying a mirror

CREATED: Creation Time

Size: Mirrored size remove mirror, such as delete Nginx mirror

Docker RMI Nginx

can also be deleted by ID, for example, I want to remove the mirror above

Docker RMI a3c1c91c9222
Remove all mirrors
Docker Rmi-f $ (Docker images)
Three, Docker container basic command Create a new and start container, such as starting a Nginx container
Docker run--name mynginx-d-P 88:80 nginx

Here are the parameters to illustrate:

--name: Define a container name yourself

-D: Indicates running in background

-P: Port mappings, identifying the mapping of ports between host and container, 80 ports of the host's 88-port mapping container, and port consistency if this parameter is not added

In addition, the--network parameter can be added later

--network=bridge: Default option, indicates connection to the default network bridge

--network=host: Containers using the host's network

--NETWORK=CONTAINER:NAME_OR_ID: Tell Docker to let the newly created container use the network configuration of the existing container

--network=none: Do not configure the container network, users can define their own network configuration example: Start a Java container and output Hello world


What needs to be explained is the execution of the Docker Run command, which determines that the mirror exists when the container is started, does not exist, pull the mirror before starting

To view an open mirror

Docker PS

Here are seven columns to illustrate the meaning:

CONTAINER ID: Container ID, uniquely identifying a container

Image: Owning Mirror ID

Command: When a container starts and runs

CREATED: Creation Time

Status: Container state, up indicates run, exited indicates stopped

PORTS: Identifies the port number of the container outside

NAMES: Identifies the container name that is specified when the startup container executes Docker run--name, and does not specify that all containers are automatically generated for viewing

Docker Ps-a
stop container Docker stop container name or container ID, for example stop Mynginx container
Docker Stop Mynginx
Force stop container Docker kill container name or container ID
Docker Kill Mynginx
start a stopped container Docker start container name or container ID
Docker start Mynginx
Reboot container Docker restart container name or container ID
Docker Restart Mynginx
Enter container Docker exec-it container name or container ID bash-i: Standard input to container-T assign a virtual terminal
Docker exec-it Mynginx Bash
Delete Container Docker RM container name or container ID
Docker RM Mynginx
Remove all containers
Docker Rm-f $ (Docker ps-a-Q)
modify the container to form a new mirror
Docker commit-a "Chicu"-M "New image" Java newimage/java:lasted

-A: Author

-M: Description

Java: Is the name of the container I created

newimage/java:lasted: Mirrored library/Mirror name: Label





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.