docker start code example

Example 1: how to start docker

systemctl start docker.service
#(OR)
systemctl start docker
# it will start docker

Example 2: docker run restart on boot

$ docker run -d --restart unless-stopped <image>

Example 3: docker start container

$ docker start my_container

Example 4: docker create

docker create [options] IMAGE
  -a, --attach               # attach stdout/err
  -i, --interactive          # attach stdin (interactive)
  -t, --tty                  # pseudo-tty
      --name NAME            # name your image
  -p, --publish 5000:5000    # port map
      --expose 5432          # expose a port to linked containers
  -P, --publish-all          # publish all ports
      --link container:alias # linking
  -v, --volume `pwd`:/app    # mount (absolute paths needed)
  -e, --env NAME=hello       # env vars

Example 5: docker --restart example

# To limit retart attempt, add [:int]
docker run -d --restart=on-failure:3

Example 6: docker start container

docker start -a <container_id>

Tags:

Go Example