Similar issue here. It starts but then is unresponsive. Expected behavior. Run docker for mac, docker for mac is usable. Actual behavior. Even though, according to the log and the application docker is running, docker is unusable. Since Docker does not start automatically after the installation is done, let’s start the daemon manually. On Windows, search for Docker and select Docker for Windows. After you started the app, you’ll see that the Windows taskbar at the bottom or Mac’s bar at the top now shows the Docker icon.
Estimated reading time: 3 minutes Docker provides restart policiesto control whether your containers start automatically when they exit, or whenDocker restarts. Restart policies ensure that linked containers are started inthe correct order. Docker recommends that you use restart policies, and avoidusing process managers to start containers.
Restart policies are different from the
--live-restore
flag of the dockerd
command. Using --live-restore
allows you to keep your containers runningduring a Docker upgrade, though networking and user input are interrupted.Use a restart policy
To configure the restart policy for a container, use the
--restart
flagwhen using the docker run
command. The value of the --restart
flag can beany of the following:Flag | Description |
---|---|
no | Do not automatically restart the container. (the default) |
on-failure | Restart the container if it exits due to an error, which manifests as a non-zero exit code. |
always | Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. (See the second bullet listed in restart policy details) |
unless-stopped | Similar to always , except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts. |
The following example starts a Redis container and configures it to alwaysrestart unless it is explicitly stopped or Docker is restarted.
Restart policy details
Keep the following in mind when using restart policies:
- A restart policy only takes effect after a container starts successfully. Inthis case, starting successfully means that the container is up for at least10 seconds and Docker has started monitoring it. This prevents a containerwhich does not start at all from going into a restart loop.
- If you manually stop a container, its restart policy is ignored until theDocker daemon restarts or the container is manually restarted. This is anotherattempt to prevent a restart loop.
- Restart policies only apply to containers. Restart policies for swarmservices are configured differently. See theflags related to service restart.
Use a process manager
If restart policies don’t suit your needs, such as when processes outsideDocker depend on Docker containers, you can use a process manager such asupstart,systemd, orsupervisor instead.
Warning: Do not try to combine Docker restart policies with host-levelprocess managers, because this creates conflicts.
To use a process manager, configure it to start your container or service usingthe same
docker start
or docker service
command you would normally use tostart the container manually. Consult the documentation for the specificprocess manager for more details.Using a process manager inside containers
Process managers can also run within the container to check whether a process isrunning and starts/restart it if not.
Warning: These are not Docker-aware and just monitor operating system processes within the container.
Docker does not recommend this approach, because it is platform-dependent and even differs within different versions of a given Linux distribution.
containers, restart, policies, automation, administrationEstimated reading time: 4 minutes
You can use Docker Machine to:
- Install and run Docker on Mac or Windows
- Provision and manage multiple remote Docker hosts
- Provision Swarm clusters
What is Docker Machine?
Docker Machine is a tool that lets you install Docker Engine on virtual hosts,and manage the hosts with
docker-machine
commands. You can use Machine tocreate Docker hosts on your local Mac or Windows box, on your company network,in your data center, or on cloud providers like Azure, AWS, or DigitalOcean.Using
docker-machine
commands, you can start, inspect, stop, and restart amanaged host, upgrade the Docker client and daemon, and configure a Dockerclient to talk to your host.Point the Machine CLI at a running, managed host, and you can run
docker
commands directly on that host. For example, run docker-machine env default
topoint to a host called default
, follow on-screen instructions to completeenv
setup, and run docker ps
, docker run hello-world
, and so forth.Machine was the only way to run Docker on Mac or Windows previous to Dockerv1.12. Starting with the beta program and Docker v1.12, Docker Desktop forMac and Docker Desktop forWindows are available as native apps and thebetter choice for this use case on newer desktops and laptops. We encourage youto try out these new apps. The installers for Docker Desktop for Mac and Docker Desktop forWindows include Docker Machine, along with Docker Compose.
If you aren’t sure where to begin, see Get Started with Docker,which guides you through a brief end-to-end tutorial on Docker.
Why should I use it?
Docker Machine enables you to provision multiple remote Docker hosts on variousflavors of Linux.
Additionally, Machine allows you to run Docker on older Mac or Windows systems,as described in the previous topic.
Docker Machine has these two broad use cases.
- I have an older desktop system and want to run Docker on Mac or WindowsIf you work primarily on an older Mac or Windows laptop or desktop that doesn’t meet the requirements for the new Docker Desktop for Mac and Docker Desktop for Windows apps, then you need Docker Machine to run Docker Engine locally. Installing Docker Machine on a Mac or Windows box with the Docker Toolbox installer provisions a local virtual machine with Docker Engine, gives you the ability to connect it, and run
docker
commands. - I want to provision Docker hosts on remote systems
Docker Engine runs natively on Linux systems. If you have a Linux box as your primary system, and want to run
docker
commands, all you need to do is download and install Docker Engine. However, if you want an efficient way to provision multiple Docker hosts on a network, in the cloud or even locally, you need Docker Machine.Whether your primary system is Mac, Windows, or Linux, you can install Docker Machine on it and use
docker-machine
commands to provision and manage large numbers of Docker hosts. It automatically creates hosts, installs Docker Engine on them, then configures the docker
clients. Each managed host (“machine”) is the combination of a Docker host and a configured client.What’s the difference between Docker Engine and Docker Machine?
When people say “Docker” they typically mean Docker Engine, theclient-server application made up of the Docker daemon, a REST API thatspecifies interfaces for interacting with the daemon, and a command lineinterface (CLI) client that talks to the daemon (through the REST API wrapper).Docker Engine accepts
docker
commands from the CLI, such asdocker run <image>
, docker ps
to list running containers, docker image ls
to list images, and so on.Docker Machine is a tool for provisioning and managing your Dockerized hosts(hosts with Docker Engine on them). Typically, you install Docker Machine onyour local system. Docker Machine has its own command line client
docker-machine
and the Docker Engine client, docker
. You can use Machine toinstall Docker Engine on one or more virtual systems. These virtual systems canbe local (as when you use Machine to install and run Docker Engine in VirtualBoxon Mac or Windows) or remote (as when you use Machine to provision Dockerizedhosts on cloud providers). The Dockerized hosts themselves can be thought of,and are sometimes referred to as, managed “machines”.Where to go next
- Create and run a Docker host on your local system using VirtualBox
- Provision multiple Docker hosts on your cloud provider
- Provision a Docker Swarm cluster with Docker Machine (Legacy Swarm)
- Getting started with swarm mode (Docker Engine 1.12 and above)