Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting and stopping App Engine instances with Docker

I've set up an App Engine project locally using Docker (on OSX), and have been running a server using the usual "gcloud preview app run app.yaml" command. From what I can tell, this keeps creating new images over and over again. After an hour or so of work I end up with something like 30 docker images, each taking 130MB.

Eventually I'm told I can no longer bind to localhost:8080. I tried killing all containers and images, but still cannot use localhost:8080 until I reboot.

Seems like I'm not using Docker/gcloud correctly. Anyone have an idea what I might be doing wrong? Is there another way I should be restarting App Engine instances other than hitting command C and running the "run" command again?

UPDATE: After looking closer, I noticed I'm getting this message when I run an app locally and a container is created: "http: Hijack is incompatible with use of CloseNotifier". I'm not familiar enough with Docker to understand what's going on here. All searches seem to point to Go, which I am not using.

UPDATE 2: Here is the trace:

Creating container...
INFO     2015-05-05 02:23:28,293 containers.py:560] Container 1564ce4344957114312d6d1dc696ffbb4176b40ace6dcff5e4239e13ee04a8f6 created.
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/judeosborn/google-cloud-sdk/platform/google_appengine/google/appengine/tools/docker/containers.py", line 643, in _ListenToLogs
    for line in log_lines:
  File "/Users/judeosborn/google-cloud-sdk/./lib/docker/docker/client.py", line 225, in _multiplexed_response_stream_helper
    socket = self._get_raw_response_socket(response)
  File "/Users/judeosborn/google-cloud-sdk/./lib/docker/docker/client.py", line 167, in _get_raw_response_socket
    self._raise_for_status(response)
  File "/Users/judeosborn/google-cloud-sdk/./lib/docker/docker/client.py", line 119, in _raise_for_status
    raise errors.APIError(e, response, explanation=explanation)
APIError: 500 Server Error: Internal Server Error ("http: Hijack is incompatible with use of CloseNotifier")

INFO     2015-05-05 02:23:28,606 module.py:1745] New instance for module "default" serving on:
http://localhost:8080
like image 405
Jude Osborn Avatar asked May 04 '15 06:05

Jude Osborn


People also ask

How do I launch or start a docker container?

The main command to launch or start a single or multiple stopped Docker containers is docker start: You can specify the container by either using its name or ID (long or short). To create a new container from an image and start it, use docker run:

How do I stop a docker container?

Docker --net modes (bridge, hots, mapped container and none). docker stop <container> [<container>...] This will send the main process in the container a SIGTERM, followed by a SIGKILL if it doesn't stop within the grace period. The name of each container is printed as it stops.

What is Docker and how does it work?

What is Docker ? Docker is an Application Container Engine. Using it we can pack any Linux software into a self-contained, isolated container image that can be easily distributed, and run on any Host Machine. Once we have the image built or downloaded, we can use it to start containers as many as we want & run the software (s) on them.

How to kill a docker container immediately without a grace period?

To immediately kill a docker container without waiting for the grace period to end use: To stop all running containers, enter the following: The same command could be used with kill. This would stop all containers without giving them a chance to exit. This tutorial provided options to list, start, and stop, Docker containers.


2 Answers

There's an ongoing issue with Docker 1.6.x [reference] that prevents gcloud to work well with Managed VMs (as you seem to be using). Easiest workaround until it gets fixed is to downgrade Docker in your development machine to version 1.5.0, which is the latest version known to work.

For Ubuntu, you can do something like:

$ curl -sSL https://get.docker.com/ubuntu | sed 's/lxc-docker/lxc-docker-1.5.0/' | sudo sh

For other Linux distros, you might have to modify that sed pattern, though.


On the other hand, if you're using Boot2Docker under Mac OS X, follow these steps:

  1. Fully uninstall your previous Boot2Docker/Docker setup; there is a nice guide here
  2. Reinstall Boot2Docker/Docker following instructions here. IMPORTANT: You MUST stop right after completing "Install Boot2Docker" step and before "Start the Boot2Docker Application". Once you get there, open up a terminal and execute the following commands:
$ mkdir ~/.boot2docker 
$ echo 'ISOURL="https://github.com/boot2docker/boot2docker/releases/download/v1.5.0/boot2docker.iso"' > ~/.boot2docker/profile

At this point, you can continue with "Start the Boot2Docker Application" section and finish the installation. You should now have a valid Docker launchpad with which to start Managed VMs. It'd be nice to double check that you have the right versions installed by issuing:

$ boot2docker ssh docker version | egrep "(Client|Server) version"

The output should look like:

Client version: 1.5.0 Server version: 1.5.0

Now you can try again your original command:

$ gcloud preview app run app.yaml

like image 76
asamarin Avatar answered Oct 20 '22 14:10

asamarin


Try running: $ ps uax | egrep "gcloud|appserver" If you see anything running, kill it... you may even need to kill -9 it.

like image 22
Glenn Lewis Avatar answered Oct 20 '22 15:10

Glenn Lewis