Docker command line and background parameters

 

 

 

 

 

 

 

In order to let users quickly understand Docker, Docker official provides an interactive tutorial to help users master the use of Docker command line.

Docker command line

The following is a brief introduction to the Docker command list, and the details are introduced in the subsequent chapters. You can get help information on the command line by running docker or docker help command (we still use coreos on vmware as the operating environment, and this environment will be used in the following text unless otherwise specified):

core@localhost ~ $ docker
Usage: docker [OPTIONS] COMMAND [arg...]
 -H=[unix:///var/run/docker.sock]: tcp://host:port to bind/connect to or unix://path/to/socket to use

A self-sufficient runtime for linux containers.

Commands:
	attach	Attach to a running container
	build	 Build an image from a Dockerfile
	commit	Create a new image from a container's changes
	cp		Copy files/folders from a container's filesystem to the host path
	diff	  Inspect changes on a container's filesystem
	events	Get real time events from the server
	export	Stream the contents of a container as a tar archive
	history   Show the history of an image
	images	List images
	import	Create a new filesystem image from the contents of a tarball
	info	  Display system-wide information
	inspect   Return low-level information on a container
	kill	  Kill a running container
	load	  Load an image from a tar archive
	login	 Register or log in to a Docker registry server
	logout	Log out from a Docker registry server
	logs	  Fetch the logs of a container
	port	  Lookup the public-facing port that is NAT-ed to PRIVATE_PORT
	pause	 Pause all processes within a container
	ps		List containers
	pull	  Pull an image or a repository from a Docker registry server
	push	  Push an image or a repository to a Docker registry server
	restart   Restart a running container
	rm		Remove one or more containers
	rmi	   Remove one or more images
	run	   Run a command in a new container
	save	  Save an image to a tar archive
	search	Search for an image on the Docker Hub
	start	 Start a stopped container
	stop	  Stop a running container
	tag	   Tag an image into a repository
	top	   Lookup the running processes of a container
	unpause   Unpause a paused container
	version   Show the Docker version information
	wait	  Block until a container stops, then print its exit code
  • Where info and version are commands related to system environment information
  • events, history, logs are commands related to log information
  • login\pull\push\search is a command related to the DockerHub service
  • The rest are commands related to daily maintenance

command syntax

Basic usage: command + parameter

core@localhost ~ $ docker info
Containers: 7
Images: 123
Storage Driver: btrfs
Execution Driver: native-0.2
Kernel Version: 3.16.2+
Operating System: CoreOS 444.0.0
core@localhost ~ $ docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.1
Git commit (client): fa7b24f
OS/Arch (client): linux/amd64
Server version: 1.2.0
Server API version: 1.14
Go version (server): go1.3.1
Git commit (server): fa7b24f

Single character arguments can be put together:

core@localhost ~ $ docker run -t -i ubuntu:14.04 /bin/bash
#使用分开的参数
root@d512e393fc74:/# exit
exit
core@localhost ~ $ docker run -ti ubuntu:14.04 /bin/bash
#将当个支付的参数放在一起
root@d170dacef325:/# exit
exit
core@localhost ~ $ docker rm d51 d17
#多个参数放在一行
d51
d17
core@localhost ~ $

Docker background process parameters

Parameter introduction
--api-enable-cors = false Remote API calls.
-b, --bridge="" Bridge a bridge device on a system to a Docker container, use none to disable networking in the container
--bip="" Use the CIDR address to set the IP of the bridge. This parameter and -b cannot be used together.
-D, --debug=false Enable Debug mode. For example: docker -d -D
-d, --daemon=false Enable Daemon mode.
--dns=[] Set the container to use the DNS server. For example: docker -d --dns 8.8.8.8
-dns-search=[] Sets the container to use the specified DNS to search for domain names. For example: docker -d --dns-search example.com
--exec-driver="native" Sets the container to use the specified runtime driver. Such as: docker -d -e lxc
-G, --group="docker" In background mode, assign the specified Group to the corresponding unix socket. Note that when this parameter --group is given an empty string, the group information will be removed
-g, --graph="/var/lib/docker" Set the Docker runtime root directory
-H, --host=[] Set the specified socket binding in background mode, you can bind one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd. For example: $ docker -H tcp://0.0.0.0:2375 ps or $ export DOCKER_HOST="tcp://0.0.0.0:2375"$ docker ps
-icc=true Set to enable communication for inline containers.
--ip="0.0.0.0" Set the default IP address used when the container is bound to IP
--ip-forward=true Set net.ipv4.ip_forward to start the container
--iptables=true Set custom iptable rules for launching Docker containers
--man = 0 Set the MTU value of the container network. If this parameter is not present, the default route MTU is used. If there is no default route, it is set to a constant value of 1500.
-p, --pidfile="/var/run/docker.pid" Set the background process PID file path.
-r, --restart=true Set the container that was running before restart
-s, --storage-driver="" Set the container runtime to use the specified storage driver, for example, specify the use of devicemapper, you can do this: docker -d -s devicemapper
--selinux-enabled=false Set to enable selinux support
--storage-opt=[] Set the parameters of the storage driver

Docker configuration file location

Docker's configuration file can set most of the background process parameters, and the storage location in each operating system is inconsistent.

The location in ubuntu is: /etc/default/docker

The location in centos is: /etc/sysconfig/docker

 

http://www.tuicool.com/articles/NfiABz

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326804016&siteId=291194637
Recommended