So I'm building an Elixir/Phoenix application and I've got the following docker-compose service:
dev:
extends:
service: common
environment:
POSTGRES_HOST: "postgres.dev"
MIX_ENV: dev
ports:
- "4000:4000"
depends_on:
- postgres
command: >
bash -c '
cd $$APP_HOME \
&& mix ecto.create \
&& mix ecto.migrate \
&& iex -S mix phx.server'
and this effectively runs the app on 0.0.0.0:4000:
Erlang/OTP 20 [erts-9.1.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]
[info] Running MyApp.Endpoint with Cowboy using http://0.0.0.0:4000
Checking with docker ps the ports are not exposed:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7a1d80cf0511 app_dev "bash -c ' cd $APP..." 4 minutes ago Up 4 minutes app_dev_run_2
ef7bed51cf24 postgres:10.0 "docker-entrypoint..." 16 minutes ago Up 16 minutes 0.0.0.0:5432->5432/tcp app_postgres_1
While the Postgres service has the exposed port and I effectively can connect to it via a GUI:
postgres:
image: postgres:10.0
ports:
- "5432:5432"
networks:
default:
aliases:
- postgres.dev
restart: always
I don't understand why the dev service does not expose the ports when they're the exact same command/definitions but using 4000 instead of 5432.
I've tried stopping, deleting all containers, networks and images but this still persists.
I don't have any EXPOSE commands in my Dockerfile and I'm running the service with docker-compose run dev.
Any help?
0.0.0.0:4000->4000/tcpindocker ps) I can do it runningdocker run -p 4000:4000 app_devbut I'd like to obtain the same behaviour with adocker-composeservice - Sasha Fonseca