Colin Murphy
Colin Murphy

Reputation: 1155

Vagrant managed docker container doesn't start

I've been trying to write a vagrant file to start up my docker container to run a small web app I've been writing. However when I try use vagrant up I eventually get an error saying

The container started either never left the "stopped" state or
very quickly reverted to the "stopped" state. This is usually
because the container didn't execute a command that kept it running,
and usually indicates a misconfiguration.

If you meant for this container to not remain running, please
set the Docker provider configuration "remains_running" to "false":

  config.vm.provider "docker" do |d|
    d.remains_running = false
  end

I'm very new to vagrant so I'm not really sure what the best way to try and fix the problem is.

My vagrant file contains

Vagrant.configure("2") do |config|

  config.vm.synced_folder "thelibrary", "/thelibrary"

  config.vm.provider "docker" do |d|
    d.image           = "django-dev"
    d.has_ssh         = false
    d.ports           = ["8000:8000"]
    d.cmd = ["python", "/thelibrary/manage.py", "runserver", "0.0.0.0:8000"]

  end

end

I'm not sure why it says the command doesn't keep running. I can run the docker container with the same command and it will spin up my django app without any issues.

Upvotes: 1

Views: 1601

Answers (2)

Andrey Bogatyrev
Andrey Bogatyrev

Reputation: 31

I had the same problem but adding option

d.create_args = ["-i"]

solved my problem

Upvotes: 2

Hy L
Hy L

Reputation: 582

I spent the day try to get the docker machine running.. finally got it working. Here is what I have in my vangrantfile, hope this can at least get you started:

config.vm.provider :docker do |d|
    d.image = "paintedfox/postgresql"
    d.name = "db"
    d.cmd = ["/sbin/my_init", "--enable-insecure-key"]
end

vagrant status returns me this:

Current machine states:
dev running (docker)

Another solution that you can try is to remove all your existing images and start fresh, it could be that your image is broken.

Upvotes: 0

Related Questions