Hakaishin
Hakaishin

Reputation: 2942

What happens when I run `docker start image_name`?

I understand that docker start starts a container and docker run creates and starts a container given an image. But naively at first I just ran the command docker start image_name and it just outputs image_name to the console and no container is created and started.

Does docker start image_name do anything besides echo the name to the console? The doc is not very illustrative. If so, what a bad way to fail, better would have been to tell me, that that is not a container but an image and I should first create a container, but maybe I'm missing some useful action which docker start image_name does?

Upvotes: 0

Views: 343

Answers (1)

KamilCuk
KamilCuk

Reputation: 141493

What happens when I run docker start image_name?

$ docker start --help

Usage:  docker start [OPTIONS] CONTAINER [CONTAINER...]

Start one or more stopped containers

it just outputs image_name to the console and no container is created and started

a, --attach               Attach STDOUT/STDERR and forward signals

The default is not to attach.

Does docker start image_name do anything besides echo the name to the console?

Yes it Start(-s) one or more stopped containers.

I'm missing some useful action which docker docker start image_name does?

It restarts the stopped container.

$ docker run --name work alpine sh -c 'echo important_work ; sleep 10 ; echo success'
important_work
success
$ docker start -a work
important_work
success

Most probably your container that you tested does nothing or expects interactive session to work, and without input it just exits.

Upvotes: 1

Related Questions