docker service create

Estimated reading time: 3 minutes

Description

Create a new service

Usage

docker service create [OPTIONS] IMAGE [COMMAND] [ARG...]

Options

Name, shorthand Default Description
--constraint   Placement constraints
--container-label   Container labels
--dns   Set custom DNS servers
--dns-option   Set DNS options
--dns-search   Set custom DNS search domains
--endpoint-mode vip Endpoint mode (vip or dnsrr)
--env, -e   Set environment variables
--env-file   Read in a file of environment variables
--group   Set one or more supplementary user groups for the container
--health-cmd   Command to run to check health
--health-interval   Time between running the check (ns|us|ms|s|m|h)
--health-retries 0 Consecutive failures needed to report unhealthy
--health-timeout   Maximum time to allow one check to run (ns|us|ms|s|m|h)
--host   Set one or more custom host-to-IP mappings (host:ip)
--hostname   Container hostname
--label, -l   Service labels
--limit-cpu 0.000 Limit CPUs
--limit-memory 0 Limit Memory
--log-driver   Logging driver for service
--log-opt   Logging driver options
--mode replicated Service mode (replicated or global)
--mount   Attach a filesystem mount to the service
--name   Service name
--network   Network attachments
--no-healthcheck false Disable any container-specified HEALTHCHECK
--publish, -p   Publish a port as a node port
--read-only false Mount the container’s root filesystem as read only
--replicas   Number of tasks
--reserve-cpu 0.000 Reserve CPUs
--reserve-memory 0 Reserve Memory
--restart-condition   Restart when condition is met (none, on-failure, or any)
--restart-delay   Delay between restart attempts (ns|us|ms|s|m|h)
--restart-max-attempts   Maximum number of restarts before giving up
--restart-window   Window used to evaluate the restart policy (ns|us|ms|s|m|h)
--secret   Specify secrets to expose to the service
--stop-grace-period   Time to wait before force killing a container (ns|us|ms|s|m|h)
--tty, -t false Allocate a pseudo-TTY
--update-delay 0s Delay between updates (ns|us|ms|s|m|h) (default 0s)
--update-failure-action pause Action on update failure (pause|continue)
--update-max-failure-ratio 0 Failure rate to tolerate during an update
--update-monitor 0s Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s)
--update-parallelism 1 Maximum number of tasks updated simultaneously (0 to update all at once)
--user, -u   Username or UID (format: <name|uid>[:<group|gid>])
--with-registry-auth false Send registry authentication details to swarm agents
--workdir, -w   Working directory inside the container

Parent command

Command Description
docker service Manage services
Command Description
docker service create Create a new service
docker service inspect Display detailed information on one or more services
docker service logs Fetch the logs of a service
docker service ls List services
docker service ps List the tasks of one or more services
docker service rm Remove one or more services
docker service scale Scale one or multiple replicated services
docker service update Update a service
chat icon Feedback? Suggestions? Can't find something in the docs?
Edit this page Request docs changes Get support
Rate this page: