Last active
June 18, 2020 05:51
-
-
Save Ocramius/7db135c674b635a96e5609df28e9da04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
- docker:dind | |
variables: | |
DOCKER_DRIVER: overlay2 | |
build-test-containers: | |
image: tiangolo/docker-with-compose | |
before_script: | |
- docker info | |
- docker-compose --version | |
script: | |
- cd tests/e2e | |
- docker-compose up --build -d | |
- sleep 30 | |
- docker-compose run build-tools entry-point ping -c 4 dependency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
mysql: | |
build: | |
context: docker/mysql | |
dockerfile: Dockerfile | |
networks: | |
another-test-network: | |
aliases: | |
- "db.test" | |
build-tools: | |
build: | |
context: . | |
dockerfile: docker/build-tools/Dockerfile | |
depends_on: | |
- mysql | |
networks: | |
another-test-network: | |
aliases: | |
- "build-tools.test" | |
networks: | |
another-test-network: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose --version | |
docker-compose version 1.21.0, build 5920eb0 | |
$ cd tests/e2e | |
$ docker-compose -f docker-compose.ci.yml up --build -d | |
[SNIP] | |
Successfully built 473cdf77700b | |
Successfully tagged e2e_build-tools:latest | |
Creating e2e_mysql_1 ... | |
Creating e2e_mysql_1 ... done | |
Creating e2e_build-tools_1 ... | |
Creating e2e_build-tools_1 ... done | |
$ sleep 30 | |
$ docker-compose -f docker-compose.ci.yml run build-tools mysql -h db.test -u root -proot-password -e "SELECT 1;" | |
Starting e2e_mysql_1 ... | |
Starting e2e_mysql_1 ... done | |
mysql: [Warning] Using a password on the command line interface can be insecure. | |
ERROR 2005 (HY000): Unknown MySQL server host 'db.test' (2) | |
ERROR: Job failed: exit code 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
- docker:dind | |
variables: | |
DOCKER_DRIVER: overlay2 | |
build-test-containers: | |
image: tiangolo/docker-with-compose | |
before_script: | |
- docker info | |
- docker-compose --version | |
script: | |
- cd tests/e2e | |
- docker-compose up --build -d | |
- sleep 30 | |
- docker-compose run build-tools mysql -h db.test -u root -proot-password -e "SELECT 1;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
dependency: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
networks: | |
test-network: | |
aliases: | |
- "dependency.test" | |
entry-point: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
depends_on: | |
- dependency | |
networks: | |
test-network: | |
aliases: | |
- "entry-point.test" | |
networks: | |
test-network: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:latest | |
# This container doesn't do anything besides running commands you give to it | |
CMD ["sleep", "10000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose --version | |
docker-compose version 1.21.0, build 5920eb0 | |
$ cd docker-is-a-dick | |
$ docker-compose up --build -d | |
Creating network "docker-is-a-dick_test-network" with the default driver | |
Building dependency | |
Step 1/2 : FROM alpine:latest | |
latest: Pulling from library/alpine | |
Digest: sha256:e1871801d30885a610511c867de0d6baca7ed4e6a2573d506bbec7fd3b03873f | |
Status: Downloaded newer image for alpine:latest | |
---> 3fd9065eaf02 | |
Step 2/2 : CMD ["sleep", "10000"] | |
---> Running in 1df6bf145739 | |
Removing intermediate container 1df6bf145739 | |
---> 51475865900e | |
Successfully built 51475865900e | |
Successfully tagged docker-is-a-dick_dependency:latest | |
Building entry-point | |
Step 1/2 : FROM alpine:latest | |
---> 3fd9065eaf02 | |
Step 2/2 : CMD ["sleep", "10000"] | |
---> Using cache | |
---> 51475865900e | |
Successfully built 51475865900e | |
Successfully tagged docker-is-a-dick_entry-point:latest | |
Creating docker-is-a-dick_dependency_1 ... | |
Creating docker-is-a-dick_dependency_1 ... done | |
Creating docker-is-a-dick_entry-point_1 ... | |
Creating docker-is-a-dick_entry-point_1 ... done | |
$ docker-compose run entry-point ping -c 4 dependency.test | |
Starting docker-is-a-dick_dependency_1 ... | |
Starting docker-is-a-dick_dependency_1 ... done | |
PING dependency.test (172.19.0.2): 56 data bytes | |
64 bytes from 172.19.0.2: seq=0 ttl=64 time=0.087 ms | |
64 bytes from 172.19.0.2: seq=1 ttl=64 time=0.046 ms | |
64 bytes from 172.19.0.2: seq=2 ttl=64 time=0.036 ms | |
64 bytes from 172.19.0.2: seq=3 ttl=64 time=0.037 ms | |
--- dependency.test ping statistics --- | |
4 packets transmitted, 4 packets received, 0% packet loss | |
round-trip min/avg/max = 0.036/0.051/0.087 ms | |
Job succeeded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
are you having problems connecting to docker-compose container in gitlab ci ?