3

I'm trying to set-up a simple reverse proxy using nginx and a Ruby application, but I also want to have it set-up inside of Docker containers.

I've reached the point where I can run the Ruby application from inside Docker and access the running service from the host machine (my Mac OS X using Boot2Docker). But I'm now stuck trying to implement the nginx part, as I've not used it before and it seems the majority of articles/tutorials/examples on the topic use Rails (rather than a simple Sinatra/Rack application) and also utilises sockets - which I've no need of as far as I'm aware.

I'm also using Docker Compose.

The complete directory structure looks like:

├── docker-compose.yml
├── front-end
│   ├── Dockerfile
│   ├── Gemfile
│   ├── app.rb
│   ├── config.ru
├── proxy
│   ├── Dockerfile
│   ├── nginx.conf
│   └── public
│       ├── 500.html
│       ├── index.html

To see the contents of these files then refer to the following gist:

https://gist.github.com/Integralist/5cfd5c884b0f2c0c5d11

But when I run docker-compose up -d I get the following error:

Creating clientcertauth_frontend_1...
Pulling image ./front-end:latest...
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 31, in main
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 27, in dispatch
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 59, in perform_command
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 445, in up
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.project", line 184, in up
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.service", line 259, in recreate_containers
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.service", line 242, in create_container
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/docker.client", line 824, in pull
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/docker.auth.auth", line 67, in resolve_repository_name
  File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/docker.auth.auth", line 46, in expand_registry_url
docker.errors.DockerException: HTTPS endpoint unresponsive and insecure mode isn't enabled.

I'm not sure what's causing this error (a bit of googling returns https://github.com/docker/compose/issues/563 but it seems a separate issue as far as I can tell?).

I'm also not entirely sure the nginx.conf is set-up correctly if I could get past this error. The config for nginx looks like it should do a reverse proxy properly (e.g. using frontend as the upstream app server, which should then resolve to the docker ip address for the front-end container -> as you'll see I've linked the two containers together so I'd expect the front-end app to be set as an alias inside /etc/hosts of the proxy container).

Does any one know what I might be missing?

Thanks.

4

1 回答 1

1

In your gist, you are using image as a key instead of build, so docker-compose is trying to pull the image from the registry, which is failing.

Since you are building these images locally, the syntax for your docker-compose.yml file should look like this:

frontend:
  build: front-end/
  ports:
    - "8080:5000"
于 2015-05-05T00:32:21.480 回答