Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Usage of Docker clients and daemons

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "the use of Docker clients and daemons". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn the usage of Docker client and daemon.

The Docker daemon

Sudo docker daemon & you can start the docker daemon

Sudo docker daemon-help View help

Among them

-- label setting label

Sudo docker info 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 to set the

Export DOCKER_HOST

Sudo server docker start is usually used to start the docker daemon

If you use sudo server docker start to start the docker daemon

The file location for the process of docker daemon is in

/ etc/default/docker

Where DOCKER_OPTS can be filled with the option in sudo docker daemon-help

The corresponding docker client can also specify the socket of the-H connection docker daemon

For example:

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

Basic operation of container

Start the container

Sudo docker run ubuntu echo "hellow"

Start the interactive container

Sudo docker run-I-t ubuntu / bin/bash

-I-interactive=true

-t-tty=true

View the container

Sudo docker ps [- a] | [- l]

-a list all containers

-l lists a newly created container

CONTAINER ID

Unique ID established when the container is started

NAME

The name of the container that was built automatically

Sudo docker inspect CONTAINER ID or NAME

Check the container

Custom container name

Sudo docker run-- name= name-I-t ubuntu / bin/bash

Restart the stopped container

Sudo docker start [- I] NAME

Delete stop Container

Sudo docker rm NAME

Guarded container

Start the guardian container

The interactive container exits the container with Ctrl+P Ctrl+Q

Or

Start the guardian container directly

Docker run-d CONTAINER ID or NAME

Enter the container

Docker attach CONTAINER ID or NAME

View container log

Docker logs [- f] [- t] [--tail] CONTAINER ID or NAME

-f-follows=true | false default false keeps tracking

-t-timestamps=true | false default false adds time to the returned result

-tail= "all" returns the number of logs at the end

View processes in the container

Docker top CONTAINER ID or NAME

Start a new process in a running container

Docker exec [- d] [- I] [- t] CONTAINER ID or NAME [COMMAND] [ARG...]

Stop guarded container

Docker stop CONTAINER ID or NAMEdocker kill CONTAINER ID or NAME

Set the port mapping of the container

Docker run [- P] [- p]

-P-publish-all=true | false default 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 port of the host is random.

Docker run-p 8080 docker run 80-I-t ubuntu / bin/bash

Specify both the host port and the container port

Docker run-p 0.0.0.0 bin/bashdocker run 80-I-t ubuntu / bin/bash / 80-I-t ubuntu / bin/bash

Specify those ports of the mapping container

At this point, I believe you have a deeper understanding of "the use of Docker clients and daemons". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report