Checking the Docker Service Status
To verify that the Docker service is running, use the following command:Starting and Stopping the Docker Service
You can control the Docker service using the following commands:To start Docker, run:To stop Docker, run:
dockerd command, which is particularly useful for troubleshooting.
Running the Docker Daemon in the Foreground
When you run the daemon in the foreground, log messages are printed directly to the console. For example, you can start the daemon in debug mode with:--debug flag will output additional information:
Docker CLI Communication via Unix Socket
When the Docker daemon starts, it listens on an internal Unix socket at/var/run/docker.sock. This Inter-Process Communication (IPC) mechanism allows local processes, especially the Docker CLI, to interact with the daemon.
Remote Access to the Docker Daemon
If you need to manage Docker containers on a remote host—for instance, from your laptop targeting a server—you must configure the Docker daemon to listen on a TCP interface. By default, Docker listens only on the Unix socket, so it is necessary to explicitly specify a TCP host. For example, if your Docker host has an IP address of192.168.1.10 and you want to listen on port 2375, start the daemon as follows:
Exposing the Docker API over TCP without encryption or authentication represents a significant security risk. Unauthorized users who can access this interface may run containers on your host for malicious purposes.
Enabling TLS for Secure Communication
To secure the TCP interface, enable TLS encryption. First, generate TLS certificates and then start the Docker daemon with the appropriate TLS flags. TLS-secured Docker daemons typically listen on port2376.
Set the DOCKER_HOST environment variable accordingly:
Using a Configuration File
Instead of setting all the options on the command line, you can use a configuration file located at/etc/docker/daemon.json. This JSON file is not created by default, so you must create it manually. Here is an example configuration:
hosts property is an array that can include multiple listeners. Once this configuration file is in place, you no longer need to pass these options on the command line when starting Docker.
If a parameter is specified both in the
daemon.json file and via command-line flags, Docker will report a conflict and fail to start. For example, conflicting debug settings will cause an error.That concludes our lesson on Docker service configuration. For further details on Docker functionalities, please refer to the Docker Documentation.