How to start stop and restart docker service on Linux

In this article, we will see how to start stop and restart docker service on Linux.

We can start, stop or restart docker in Linux using service or systemctl commands with the sudo privleges. Also we can start using docker daemon i.e. dockerd.

How to start stop and restart docker service on Linux

1. First check whether docker is running or not on Linux.

sudo systemctl status docker sudo service docker status

How to start stop and restart docker service on Linux

2. If it is stopped run the below command to start the Docker on Linux.

sudo systemctl start docker sudo service docker start

3. If we want to stop docker service on Linux run the below command.

sudo systemctl stop docker sudo service docker stop

Then verify by running the command from step 1.

4. If we want to restart the docker service on Linux,

sudo systemctl restart docker sudo service docker restart

We can also start the docker service using dockerd daemon as shown below:

sudo dockerd

Below is the output of the above command.

r2schools@ub2022:~$ sudo dockerd INFO[2022-12-16T13:26:35.709972453+05:30] Starting up INFO[2022-12-16T13:26:35.711271728+05:30] detected 127.0.0.53 nameserver, assumi ng systemd-resolved, so using resolv.conf: /run/systemd/resolve/resolv.conf INFO[2022-12-16T13:26:35.712711011+05:30] parsed scheme: "unix" module=grpc INFO[2022-12-16T13:26:35.713050073+05:30] scheme "unix" not registered, fallback to default scheme module=grpc INFO[2022-12-16T13:26:35.713225341+05:30] ccResolverWrapper: sending update to c c: {[{unix:///run/containerd/containerd.sock 0 }] } modu le=grpc INFO[2022-12-16T13:26:35.713400975+05:30] ClientConn switching balancer to "pick _first" module=grpc INFO[2022-12-16T13:26:35.715083927+05:30] parsed scheme: "unix" module=grpc INFO[2022-12-16T13:26:35.715440514+05:30] scheme "unix" not registered, fallback to default scheme module=grpc INFO[2022-12-16T13:26:35.715603748+05:30] ccResolverWrapper: sending update to c c: {[{unix:///run/containerd/containerd.sock 0 }] } modu le=grpc INFO[2022-12-16T13:26:35.715809262+05:30] ClientConn switching balancer to "pick _first" module=grpc INFO[2022-12-16T13:26:35.758452530+05:30] [graphdriver] using prior storage driv er: overlay2 INFO[2022-12-16T13:26:35.760795642+05:30] Loading containers: start. INFO[2022-12-16T13:26:35.911763105+05:30] Default bridge (docker0) is assigned w ith an IP address 172.17.0.0/16. Daemon option --bip can be used to set a prefer red IP address INFO[2022-12-16T13:26:35.976185463+05:30] Loading containers: done. INFO[2022-12-16T13:26:36.002885233+05:30] Docker daemon commit=3056208 graphdriver(s)=overlay2 version=20.10.21 INFO[2022-12-16T13:26:36.003533175+05:30] Daemon has completed initialization INFO[2022-12-16T13:26:36.030650684+05:30] API listen on /var/run/docker.sock ^L^CINFO[2022-12-16T13:26:41.918522762+05:30] Processing signal 'interrupt' INFO[2022-12-16T13:26:41.919991787+05:30] Daemon shutdown complete r2schools@ub2022:~$ sudo dockerd INFO[2022-12-16T13:26:45.644423454+05:30] Starting up INFO[2022-12-16T13:26:45.646947335+05:30] detected 127.0.0.53 nameserver, assuming systemd-resolved, so using resolv.conf: /run/systemd/resolve/resolv.conf INFO[2022-12-16T13:26:45.648015649+05:30] parsed scheme: "unix" module=grpc INFO[2022-12-16T13:26:45.648308146+05:30] scheme "unix" not registered, fallback to default scheme module=grpc INFO[2022-12-16T13:26:45.648476728+05:30] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 }] } module=grpc INFO[2022-12-16T13:26:45.648635526+05:30] ClientConn switching balancer to "pick_first" module=grpc INFO[2022-12-16T13:26:45.650495634+05:30] parsed scheme: "unix" module=grpc INFO[2022-12-16T13:26:45.650541260+05:30] scheme "unix" not registered, fallback to default scheme module=grpc INFO[2022-12-16T13:26:45.650563631+05:30] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 }] } module=grpc INFO[2022-12-16T13:26:45.650587995+05:30] ClientConn switching balancer to "pick_first" module=grpc INFO[2022-12-16T13:26:45.673667335+05:30] [graphdriver] using prior storage driver: overlay2 INFO[2022-12-16T13:26:45.675599284+05:30] Loading containers: start. INFO[2022-12-16T13:26:45.859830028+05:30] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address INFO[2022-12-16T13:26:45.923457464+05:30] Loading containers: done. INFO[2022-12-16T13:26:45.952888695+05:30] Docker daemon commit=3056208 graphdriver(s)=overlay2 version=20.10.21 INFO[2022-12-16T13:26:45.953194755+05:30] Daemon has completed initialization INFO[2022-12-16T13:26:45.977002625+05:30] API listen on /var/run/docker.sock

If we want to quit from the console, we have to use Ctrl+C. So, it is always better use systemctl or service to start, stop or restart the Docker on Linux.

For the same, please check below video tutorial for Docker Service on Linux:

Leave a Reply

Your email address will not be published. Required fields are marked *