Home >Operation and Maintenance >Docker >How to start docker on boot
When using docker, it is often necessary to configure it to start at boot, so that the docker service can be automatically started after the server is restarted. This article will introduce how to start docker on boot.
The first step is to install docker
If docker has not been installed yet, you need to install docker first. I won’t go into details about the installation process here. You can search for relevant installation tutorials by yourself.
The second step is to create the systemd service file
On the Linux system, use systemd to manage the service. We need to create a systemd service file to define how docker is started.
Create the file /etc/systemd/system/docker.service and write the following content:
[Unit]
Description=Docker Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/dockerd
Restart=on-failure
[Install]
WantedBy=multi-user. target
The specific meaning of this file is as follows: The
After creating the service file, use systemctl to reload the configuration file to make it effective:
systemctl daemon-reload
The third step is to set up the docker service to start Start
Set the docker service to start at boot, run the following command:
systemctl enable docker.service
This command will start the docker.service service when the system starts.
The fourth step is to verify whether the docker service is started successfully.
Run the following command to check whether the docker.service service is started:
systemctl is-enabled docker.service
If the command returns "enabled", it means that the docker.service service has been successfully started.
At this point, we have set the docker service to start at boot. In this way, the docker service will start automatically after the server is restarted. Improved production efficiency and convenience.
The above is the detailed content of How to start docker on boot. For more information, please follow other related articles on the PHP Chinese website!