You are not logged in.

#1 2018-11-22 18:10:52

x-yuri
Member
Registered: 2013-01-06
Posts: 160

Publishing ports doesn't work with docker compose

Hi,

I'm trying to achieve this:

# docker run --rm -itp 4000:80 nginx
# curl localhost:4000
<outputs welcome page>

with docker compose.

docker-compose.yml:

services:
  nginx:
    image: nginx:stable
    ports:
      - "4001:80"
# docker stack deploy -c docker-compose.yml s1
# curl localhost:4001
<hangs>

On Ubuntu 18.04 it seems to work. But I can't see docker-18.09.0 there, so it must have been installed from some PPA.

I can access nginx via docker0 and docker_gwbridge NICs though. One guess is that Ubuntu takes extra steps for it to work with localhost. Or fixes some bug. Do you have any suggestions on how to make it work with localhost?

Thanks in advance.

Offline

#2 2018-12-27 04:47:57

crmullins
Member
Registered: 2014-04-08
Posts: 27

Re: Publishing ports doesn't work with docker compose

Your syntax is correct but you need to specify the version at the top:

version: '3'

Then you can run it with

docker-compose up -d

in the same directory.

Offline

Board footer

Powered by FluxBB