-1

I am trying to run GoCD server in Docker in a VM. To test the setup I created an Ubuntu 14.04 server in VirtualBox, installed Docker, and then following instructions from

https://github.com/gocd/gocd-docker & https://hub.docker.com/r/gocd/gocd-server/ I ran: docker run -tiP gocd/gocd-server

This works, but the problem is that if I close the terminal (which I'll have to do in production because I cannot keep an SSH terminal open indefinitely) the server dies. I was able to get the port this server was running on by opening another terminal to the VM and running docker PS. I was able to access that one from my browser. Of course I need a solution that allows me to close the terminal.

So I tried it again (in a fresh VM), hit Ctrl+C, waited for it to shut down, then ran:

docker rename randomDockerName gocd-server

and then

docker start gocd-server docker ps

I then see something like

randomLetters gocd/gocd-server "/sbin/my_init" 25 minutes ago Up 10 minutes 0.0.0.0:32773->8153/tcp, 0.0.0.0:32772->8154/tcp gocd-server

So I point my chrome on my Ubuntu 14.04 host machine to ipaddress:32773 and I get nothing. Now when the docker image was running with docker run this worked just fine, so why isn't this working with docker start? I can't use run again because that creates a new docker image and I have to keep the terminal open to keep the server running.

So my question is, how do I run GoCD in Docker on a VM without having to stay logged in to that VM?

Also, the Ubuntu VM is configured in VirtualBox with both a NAT and a Bridged network card.

user2915097
  • 30,758
  • 6
  • 57
  • 59
Bernard Igiri
  • 1,272
  • 2
  • 18
  • 33
  • Well I feel silly. All I had to do was Ctrl+p + Ctrl+q as per http://stackoverflow.com/questions/19688314/how-do-you-attach-and-detach-from-dockers-process – Bernard Igiri Aug 24 '15 at 17:42
  • Did you look at `docker run --restart=always` ? See the doc https://docs.docker.com/reference/commandline/run/ – user2915097 Aug 24 '15 at 18:14

1 Answers1

2

If your application really requires to have an open terminal, you can install screen. With that tool you could detach from a that process before you close your ssh connection. Next time you re-connect you could attach back to that process to get back the terminal.

An other possibility would be to run your container in background with the -d flag:

docker run -d -P gocd/gocd-server
Henrik Sachse
  • 51,228
  • 7
  • 46
  • 59