Skip to content

Docker Compose to Run

Convert the services of a Docker Compose file into docker run commands. Each service becomes one multi-line command with its ports, volumes, environment, restart policy, network, resource limits, health check, logging and other options, in YAML or JSON input. Keys docker run cannot express, such as build or depends_on, are listed above the command.

Reset

Frequently asked questions

Which compose keys are converted?

image, container_name, command, entrypoint, ports, expose, volumes, environment, env_file, restart, network_mode, networks, working_dir, user, hostname, labels, extra_hosts, capabilities, privileged, read_only, init, stdin_open, tty, memory and CPU settings including deploy.resources.limits, shm_size, stop_signal, stop_grace_period, DNS settings, devices, tmpfs, sysctls, security_opt, ulimits, logging, healthcheck, platform, pull_policy and several namespace keys.

What happens to build, depends_on and similar keys?

docker run has no equivalent for them, so they are listed in a comment above the command for that service. A service with build but no image uses the service name as the image name, so build and tag the image first.

Why does each command start with -d and --name?

Compose starts containers in the background and gives each one a name, so the commands do the same. The name is container_name when it is set, otherwise the service name.

What about services on several networks?

docker run connects a container to one network when it starts. The command uses the first network, and the others are listed in the comment; connect them afterwards with docker network connect.

Are variables like ${TAG} kept?

Yes. Values that contain a dollar sign are written in double quotes, so your shell replaces the variable when you run the command, much like Compose interpolates it. Other values are written in single quotes where needed.

Does it read the long syntax for ports and volumes?

Yes. Long port entries with target, published, host_ip and protocol and long volume entries with type, source, target and read_only are converted, and tmpfs volumes become --tmpfs.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.