1

Operating system: Windows10

Using:

  • Oracle VM VirtualBox
  • DockerToolbox v1.9.1i

Hi, do you know how to start a container automatically at boot2docker boot?

I have created a new machine with docker-machine. Then I have run a new container with docker run. It's all up and and running, but when I shutdown my Windows and try to start my docker machine the container inside doesn't start. I have tried to add docker start id command to the file /mnt/sda1/var/lib/boot2docker/profile but it doesn't work.

I have tried also to connect to the virtual machine with ssh (docker-machine ssh name) and run the command docker start id without success. Finally I have to stop and remove the container and make a docker run again.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

0

I suspect your container don't start because when the machine (the boot2docker VM) restarts, it still has it in an 'Exited' state.

Confirm with a docker-machine ssh default "docker ps -a". (after a docker-machine start default)

If so, add in your /mnt/sda1/var/lib/boot2docker/profile a call to a script which will:

  • test if the container is exited:

    docker inspect -f {{.State.Running}} $CONTAINER_ID
    
  • if the previous command

    • errors, it means the container is not runnig at all: docker run
    • returns false, docker rm + docker run
    • return true: nothing to do.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250