Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Created November 14, 2019 14:17
Show Gist options
  • Save zeitounator/42ac6a9f1cdbdddb2292d175c57d8125 to your computer and use it in GitHub Desktop.
Save zeitounator/42ac6a9f1cdbdddb2292d175c57d8125 to your computer and use it in GitHub Desktop.
---
version: "3.7"
services:
postgres:
image: "postgres:11.0-alpine"
app:
build: .
ports:
- "4000:4000"
depends_on:
- postgres
- nuxt
nuxt:
image: node:latest
ports:
- "3000:3000"
command: 'bash -c "while true; do sleep 2000; done"'
# Dummy file to have an app service
FROM debian:buster
CMD while true; do sleep 2000; done
# Note: "toto" is the name of my test folder (hence docker-compose project name).
$ docker-compose up -d
Creating network "toto_default" with the default driver
Creating toto_nuxt_1 ... done
Creating toto_postgres_1 ... done
Creating toto_app_1 ... done
$ docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------
toto_app_1 /bin/sh -c while true; do ... Up 0.0.0.0:4000->4000/tcp
toto_nuxt_1 docker-entrypoint.sh bash ... Up 0.0.0.0:3000->3000/tcp
toto_postgres_1 docker-entrypoint.sh postgres Up 5432/tcp
$ docker-compose exec nuxt bash
root@428c01bd1363:/# ping postgres
PING postgres (192.168.80.3) 56(84) bytes of data.
64 bytes from toto_postgres_1.toto_default (192.168.80.3): icmp_seq=1 ttl=64 time=0.356 ms
64 bytes from toto_postgres_1.toto_default (192.168.80.3): icmp_seq=2 ttl=64 time=0.171 ms
^C
--- postgres ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.171/0.263/0.356/0.093 ms
root@428c01bd1363:/# ping app
PING app (192.168.80.4) 56(84) bytes of data.
64 bytes from toto_app_1.toto_default (192.168.80.4): icmp_seq=1 ttl=64 time=0.108 ms
64 bytes from toto_app_1.toto_default (192.168.80.4): icmp_seq=2 ttl=64 time=0.088 ms
64 bytes from toto_app_1.toto_default (192.168.80.4): icmp_seq=3 ttl=64 time=0.115 ms
^C
--- app ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2046ms
rtt min/avg/max/mdev = 0.088/0.103/0.115/0.016 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment