https://github.com/rgl/ubuntu-docker-compose-example
example on how to start a docker compose environment in a (remote) docker host
https://github.com/rgl/ubuntu-docker-compose-example
docker docker-compose ubuntu
Last synced: about 2 months ago
JSON representation
example on how to start a docker compose environment in a (remote) docker host
- Host: GitHub
- URL: https://github.com/rgl/ubuntu-docker-compose-example
- Owner: rgl
- Created: 2020-08-08T21:40:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-10-04T18:51:29.000Z (9 months ago)
- Last Synced: 2025-10-04T20:30:07.051Z (9 months ago)
- Topics: docker, docker-compose, ubuntu
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# About
[](https://github.com/rgl/ubuntu-docker-compose-example/actions/workflows/build.yml)
This is an example on how to start a docker-compose environment in a (remote) docker host.
**NB** This is similar to [rgl/windows-docker-compose-example](https://github.com/rgl/windows-docker-compose-example).
# Usage
Execute the following commands:
```bash
# if required, set the DOCKER_HOST environment variable.
# this make the docker client use this dockerd.
# NB you must start dockerd with -H tcp://0.0.0.0:2375
#export DOCKER_HOST=tcp://10.1.0.2:2375
# create the environment defined in docker-compose.yml
# and leave it running in the background.
docker compose up --build -d
# show running containers.
docker compose ps
# execute command inside the containers.
docker compose exec -T hello ls -laF /
docker compose exec -T etcd etcd --version
docker compose exec -T etcd etcdctl version
docker compose exec -T etcd etcdctl endpoint health
docker compose exec -T etcd etcdctl put foo bar
docker compose exec -T etcd etcdctl get foo
# get the allocated hello port and create an endpoint url based in
# the DOCKER_HOST environment variable host.
hello_endpoint="$(
python3 <<'EOF'
import os
import urllib.parse
import subprocess
p = subprocess.Popen(
['docker', 'compose', 'port', 'hello', '8888'],
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout, stderr = p.communicate()
if 'DOCKER_HOST' in os.environ:
docker_host_ip_address = urllib.parse.urlparse(os.environ['DOCKER_HOST']).netloc.split(':')[0]
hello_port = stdout.strip().split(':')[-1]
hello_endpoint = f'http://{docker_host_ip_address}:{hello_port}'
else:
hello_endpoint = f'http://{stdout.strip()}'
print(hello_endpoint)
EOF
)"
# invoke the hello endpoint.
wget -qO- $hello_endpoint
# show logs.
docker compose logs
# destroy the environment.
docker compose down --volumes
```