Configuring the Docker
You can run commands through the command line or use the service (configured by the configuration file) to start the Docker.
- Run the following command to start Docker:
docker daemon -D #Start Docker using the commandline. –D enables the commission. If you want to sto the commissionp, kill the Docker process.
- Use the systemd service to start Docker.
systemctl start docker #Start Docker using the service. If you want to stop the Docker, change start to stop.
Users can modify the /usr/lib/systemd/system/docker.service file to modify startup parameters of Docker.
# vim /usr/lib/systemd/system/docker.service [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network.target [Service] Type=notify EnvironmentFile=-/etc/sysconfig/docker EnvironmentFile=-/etc/sysconfig/docker-storage EnvironmentFile=-/etc/sysconfig/docker-network Environment=GOTRACEBACK=crash # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker ExecStart=/usr/bin/docker daemon $OPTIONS \ $DOCKER_STORAGE_OPTIONS \ $DOCKER_NETWORK_OPTIONS \ $ADD_REGISTRY \ $BLOCK_REGISTRY \ $INSECURE_REGISTRY LimitNOFILE=1048576 LimitNPROC=1048576 LimitCORE=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process [Install] WantedBy=multi-user.target
- Run the systemctl restart docker command to restart the service and make configurations to take effect.
- EnvironmentFile=-/etc/sysconfig/docker: defines the file where environment variables locate. Environment variables defined in the file can be quoted in the /usr/lib/systemd /system/docker.service file.
- Startup parameters of Docker must be added to the end of ExecStart.
- Configuring external network proxy of Docker.
If you want to pull images from Docker Hub, you need to set the proxy.
- Add following contents to the /usr/lib/systemd/system/docker.service directory:
Environment="HTTP_PROXY=http://count:passwd@proxyhk.huawei.com:8080"
- Run the following command to restart the daemon and make the configuration take effect:
systemctl restart docker
- Add following contents to the /usr/lib/systemd/system/docker.service directory: