Docker Study Notes (2) -- Docker client and daemon

Source: Internet
Author: User
Tags add time docker stop container docker ps

Docker Study Notes (2) -- Docker client and daemon
Docker daemon

Sudo docker daemon & you can start the docker daemon process

Sudo docker daemon-help to view help
Where

-- Label setting label sudo docker info you can view the label option-H specifies the socket of the docker daemon, which can be: tcp: // host: post unix: /// patch/to/socket fd: // * or fd: // socketfd

You can also set the DOCKER_HOST environment variable.

export DOCKER_HOST 

 

Generally, the sudo server docker start is used to start the docker daemon process.

If you use sudo server docker start to start the docker daemon
The docker daemon process configuration file is located

/etc/default/docker

Here, DOCKER_OPTS can be filled with the options in sudo docker daemon-help.

The corresponding docker client can also specify-H to connect to the socket of the docker daemon.

For example:

docker -H tcp://127.0.0.1:2375 run -it ubuntu:14.04 /bin/bash

 

Basic container operations Start container

sudo docker run ubuntu echo “hellow”

Start interactive container

sudo docker run -i -t ubuntu /bin/bash

-i –interactive=true
-t –tty=true

View containers
sudo docker ps [-a ]|[ -l]

-A: List all containers.
-L list the newly created container

CONTAINER ID
Unique ID created during container startup
NAME
Name of the automatically created container

sudo docker inspect CONTAINER ID or NAME

Check containers

Custom container name
Sudo docker run -- name = name-I-t ubuntu/bin/bash
Restart the stopped container
sudo docker start [-i]  NAME
Delete the stop container
sudo docker rm NAME

 

Daemon container Start a daemon container

Interactive container exit container with Ctrl + P Ctrl + Q

Or

Start the daemon container directly

docker run -d CONTAINER ID or NAME 
Enter container
docker attach CONTAINER ID or NAME
View container logs
docker logs [-f] [-t] [--tail] CONTAINER ID or NAME 

-F-follows = true | false: Default Value: false. Keep tracking.
-T-timestamps = true | false by default, false is used to add time to the returned result.
-Tail = "all": returns the number of logs at the end.

View processes in a container
docker top CONTAINER ID or NAME 
Start a new process in the running container
docker exec [-d] [-i] [-t]  CONTAINER ID or NAME  [COMMAND] [ARG ...]
Stop a daemon container
docker stop CONTAINER ID or NAMEdocker kill CONTAINER ID or NAME
Set container port ing
docker run [-P] [-p]

-P-publish-all = true | false default value: false
Docker run-P-I-t ubuntu/bin/bash

Map all ports exposed by the container

-p –publish=[]

Docker run-p 80-I-t ubuntu/bin/bash
Only specify the port of the container to be mapped. The host machine port is random.

Docker run-p 8080: 80-I-t ubuntu/bin/bash
Specify both host port and container port

docker run -p 0.0.0.0:80 -i -t ubuntu /bin/bash

docker run -p 0.0.0.0:8080:80 -i -t ubuntu /bin/bash

Specify the ports of the ing container

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.