1. Set Boot up
If you want Docker-to-start at boot, you should also:
$ sudo systemctl enable docker
2. Start, stop, restart
$ sudo systemctl start docker
$ sudo systemctl stop Docker
$ sudo systemctl restart Docker
3. Turn on local and remote
Modify the/etc/sysconfig/docker file, replace
-H fd://
-H unix:///var/run/docker.sock -H 0.0.0.0:2376
4.boot2docker Startup Parameters
/usr/local/bin/docker-d-d-g/var/lib/docker-h unix://-H tcp://0.0.0.0:2376--tlsverify--tlscacert=/var/lib/ Boot2docker/tls/ca.pem--tlscert=/var/lib/
5. Confirm Docker Boot
Verify that the docker Daemon is running as specified ps with the command.
$ ps aux | grep Docker | Grep-v grep
Configuring and running Docker on various distributions
After successfully installing Docker, the docker daemon runs with its default configuration.
In a production environment, system administrators typically configure the docker daemon to start and stop according to an O Rganization ' s requirements. In most cases, the system administrator configures a process manager such as SysVinit , Upstart or to systemd manage the docker da Emon ' s start and stop.
Running the Docker daemon directly
The docker daemon can be run directly using the -d option. By default it listens on the Unix socketunix:///var/run/docker.sock
$ docker -dINFO[0000] +job init_networkdriver()INFO[0000] +job serveapi(unix:///var/run/docker.sock)INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)......
Configuring the Docker daemon directly
If you ' re running docker the daemon directly by running docker -d instead of the using a Process manager, you can append the Config Uration options to the docker Run command directly. Just like -d the option, and other options can is passed to the docker daemon to configure it.
Some of the daemon ' s options are:
| Flag |
Description |
-D,--debug=false |
Enable or disable debug mode. By default, this is false. |
-H,--host=[] |
Daemon socket (s) to connect to. |
--tls=false |
Enable or disable TLS. By default, this is false. |
Here are a example of running the docker daemon with configuration options:
$ docker -d -D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376
These options:
- Enable
-D (Debug) mode
- Set to True with the
tls server certificate and key specified using --tlscert and --tlskey respectively
- Listen for connections on
tcp://192.168.59.3:2376
The command line reference have the complete list of daemon flags with explanations.
Ubuntu
14.04as of, Ubuntu uses upstart as a process manager. By default, upstart jobs is located in and the /etc/init docker upstart job can is found at /etc/init/docker.conf .
After successfully installing Docker for Ubuntu, you can check the running status using upstart in the this-to:
$ sudo status dockerdocker start/running, process 989
Running Docker
You can start/stop/restart the docker daemon using
$ sudo start docker$ sudo stop docker$ sudo restart docker
Configuring Docker
You configure the daemon with the file on the docker /etc/default/docker your system. Specifying values in a DOCKER_OPTS variable.
To configure Docker options:
Log into your host as a user with sudo or root privileges.
If you don't have one, create the file on /etc/default/docker your host. Depending on how to installed Docker, you may already has this file.
Open the file with your favorite editor.
$ sudo vi /etc/default/docker
ADD a DOCKER_OPTS variable with the following options. These options is appended to the docker daemon ' Run command.
DOCKER_OPTS="-D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376"
These options:
- Enable
-D (Debug) mode
- Set to True with the
tls server certificate and key specified using --tlscert and --tlskey respectively
- Listen for connections on
tcp://192.168.59.3:2376
The command line reference have the complete list of daemon flags with explanations.
Save and close the file.
Restart the docker daemon.
$ sudo restart docker
Verify The daemon is running as specified with the docker ps command.
$ ps aux | grep docker | grep -v grep
Logs
By default logs for upstart jobs is located in and the /var/log/upstart logs for docker Daemon can is located at/var/log/upstart/docker.log
-f /var/log/upstart/docker.logINFO[0000] Loading containers: done.INFO[0000] docker daemon: 1.6.0 4749651; execdriver: native-0.2; graphdriver: aufsINFO[0000] +job acceptconnections()INFO[0000] -job acceptconnections() = OK (0)INFO[0000] Daemon has completed initialization
centos/red Hat Enterprise Linux/fedora
7.xas of, CentOS and RHEL use as the systemd process Manager. 21as of, Fedora uses as its systemd process manager.
After successfully installing Docker for centos/red Hat Enterprise Linux/fedora, you can check the running status on this By:
$ sudo systemctl status docker
Running Docker
You can start/stop/restart the docker daemon using
$ sudo systemctl start docker$ sudo systemctl stop docker$ sudo systemctl restart docker
If you want Docker-to-start at boot, you should also:
enable docker
Configuring Docker
You configure the docker daemon with the /etc/sysconfig/docker file on your host. Specifying values in a variable. For CentOS 7.x and Rhel 7.x, the name of the variable OPTIONS are and for CentOS 6.x and Rhel 6.x, the name of the variable i S other_args . For this section, we'll use the CentOS 7.x as a example to configure the docker daemon.
By default, SYSTEMD services is located either /etc/systemd/service in, /lib/systemd/system or /usr/lib/systemd/system . The docker.service file can be found in either of these three directories depending on your host.
To configure Docker options:
Log into your host as a user with sudo or root privileges.
If you don't have one, create the file on /etc/sysconfig/docker your host. Depending on how to installed Docker, you may already has this file.
Open the file with your favorite editor.
$ sudo vi /etc/sysconfig/docker
ADD a OPTIONS variable with the following options. These options is appended to the command that starts the docker daemon.
OPTIONS="-D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376"
These options:
- Enable
-D (Debug) mode
- Set to True with the
tls server certificate and key specified using --tlscert and --tlskey respectively
- Listen for connections on
tcp://192.168.59.3:2376
The command line reference have the complete list of daemon flags with explanations.
Save and close the file.
Restart the docker daemon.
$ sudo service docker restart
Verify The daemon is running as specified with the docker ps command.
$ ps aux | grep docker | grep -v grep
Logs
SYSTEMD have its own logging system called the journal. The logs for the docker daemon can be viewed usingjournalctl -u docker
$ sudo journalctl-u dockermay0600:22:Localhost.localdomain systemd[1]: Starting Docker application Container Engine ... May0600:22:Localhost.localdomain docker[2495]: time="2015-05-06t00:22:05z" level="Info" msg="+job Serveapi (Unix:///var/run/docker.sock)" may0600:22:Localhost.localdomain docker[2495]: time="2015-05-06t00:22:05z" level="Info" msg="Listening for HTTP in Unix (/var/run/docker.sock)" may0600:22:Localhost.localdomain docker[2495]: time="2015-05-06t00:22:06z" level="Info" msg="+job Init_networkdriver ()" May0600:22:Localhost.localdomain docker[2495]: time="2015-05-06t00:22:06z" level="Info" msg="-job init_networkdriver () = OK (0)" may0600:22:Localhost.localdomain docker[2495]: time="2015-05-06t00:22:06z" level="Info" msg="Loading Containers:start." May0600:22:Localhost.localdomain docker[2495]: time="2015-05-06t00:22:06z" level="Info" msg="Loading Containers:done." May0600:22:Localhost.localdomain docker[2495]: time="2015-05-06t00:22:06z" level="Info" msg="Docker Daemon:1.5.0-dev fc0329b/1.5.0; execdriver:native-0.2; Graphdriver:devicemapper "may : localhost.localdomain docker[2495]: time=" 2015-05-06t00:22:06z "level=" info "msg=" +job acceptconnections () "May :06 Localhost.localdomain docker[2495]: time="2015-05-06t00:22:06z" level= "info" msg="-job Acceptconnections () = OK (0) "
Note:using and Configuring journal is a advanced topic and are beyond the scope of this article.
Docker set up and run some commands and text