简体   繁体   中英

Docker Containers not running on boot2docker boot

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM