$ -weight: 500;">docker network create dtstack
$ -weight: 500;">docker run -d --rm --name dtpg \ --network dtstack \ -e POSTGRES_PASSWORD=-weight: 500;">docker \ -e POSTGRES_DB=testdb \ -v pgdata:/var/lib/postgresql/data \ --tmpfs /var/run/postgresql \ postgres:17
$ -weight: 500;">docker run -d --rm --name cloudbeaver \ --network dtstack \ -p 8978:8978 \ -v cbdata:/opt/cloudbeaver/workspace \ dbeaver/cloudbeaver:latest
$ -weight: 500;">docker network create dtstack
$ -weight: 500;">docker run -d --rm --name dtpg \ --network dtstack \ -e POSTGRES_PASSWORD=-weight: 500;">docker \ -e POSTGRES_DB=testdb \ -v pgdata:/var/lib/postgresql/data \ --tmpfs /var/run/postgresql \ postgres:17
$ -weight: 500;">docker run -d --rm --name cloudbeaver \ --network dtstack \ -p 8978:8978 \ -v cbdata:/opt/cloudbeaver/workspace \ dbeaver/cloudbeaver:latest
$ -weight: 500;">docker network create dtstack
$ -weight: 500;">docker run -d --rm --name dtpg \ --network dtstack \ -e POSTGRES_PASSWORD=-weight: 500;">docker \ -e POSTGRES_DB=testdb \ -v pgdata:/var/lib/postgresql/data \ --tmpfs /var/run/postgresql \ postgres:17
$ -weight: 500;">docker run -d --rm --name cloudbeaver \ --network dtstack \ -p 8978:8978 \ -v cbdata:/opt/cloudbeaver/workspace \ dbeaver/cloudbeaver:latest
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
$ mkdir -p dtstack-pg && cd dtstack-pg
$ mkdir -p dtstack-pg && cd dtstack-pg
$ mkdir -p dtstack-pg && cd dtstack-pg
services: dtpg: container_name: dtpg image: postgres:17 environment: POSTGRES_PASSWORD: -weight: 500;">docker POSTGRES_DB: testdb volumes: - pgdata:/var/lib/postgresql/data tmpfs: - /var/run/postgresql volumes: pgdata:
services: dtpg: container_name: dtpg image: postgres:17 environment: POSTGRES_PASSWORD: -weight: 500;">docker POSTGRES_DB: testdb volumes: - pgdata:/var/lib/postgresql/data tmpfs: - /var/run/postgresql volumes: pgdata:
services: dtpg: container_name: dtpg image: postgres:17 environment: POSTGRES_PASSWORD: -weight: 500;">docker POSTGRES_DB: testdb volumes: - pgdata:/var/lib/postgresql/data tmpfs: - /var/run/postgresql volumes: pgdata:
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
[+] Running 3/3 β Network dtstack-pg_default Created β Volume dtstack-pg_pgdata Created β Container dtpg Started
[+] Running 3/3 β Network dtstack-pg_default Created β Volume dtstack-pg_pgdata Created β Container dtpg Started
[+] Running 3/3 β Network dtstack-pg_default Created β Volume dtstack-pg_pgdata Created β Container dtpg Started
$ -weight: 500;">docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
dtpg postgres:17 "-weight: 500;">docker-entrypoint.sβ¦" dtpg 54 seconds ago Up 54 seconds 5432/tcp
$ -weight: 500;">docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
dtpg postgres:17 "-weight: 500;">docker-entrypoint.sβ¦" dtpg 54 seconds ago Up 54 seconds 5432/tcp
$ -weight: 500;">docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
dtpg postgres:17 "-weight: 500;">docker-entrypoint.sβ¦" dtpg 54 seconds ago Up 54 seconds 5432/tcp
$ -weight: 500;">docker compose logs
$ -weight: 500;">docker compose logs
$ -weight: 500;">docker compose logs
dtpg | PostgreSQL init process complete; ready for -weight: 500;">start up.
dtpg | database system is ready to accept connections
dtpg | PostgreSQL init process complete; ready for -weight: 500;">start up.
dtpg | database system is ready to accept connections
dtpg | PostgreSQL init process complete; ready for -weight: 500;">start up.
dtpg | database system is ready to accept connections
$ -weight: 500;">docker compose logs -f
$ -weight: 500;">docker compose logs -f
$ -weight: 500;">docker compose logs -f
$ -weight: 500;">docker compose exec dtpg psql -U postgres -c "SELECT version();"
$ -weight: 500;">docker compose exec dtpg psql -U postgres -c "SELECT version();"
$ -weight: 500;">docker compose exec dtpg psql -U postgres -c "SELECT version();"
version
-------------------------------------------------------------------------------------------------------------------- PostgreSQL 17.9 (Debian 17.9-1.pgdg13+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
(1 row)
version
-------------------------------------------------------------------------------------------------------------------- PostgreSQL 17.9 (Debian 17.9-1.pgdg13+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
(1 row)
version
-------------------------------------------------------------------------------------------------------------------- PostgreSQL 17.9 (Debian 17.9-1.pgdg13+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
(1 row)
$ -weight: 500;">docker compose down
$ -weight: 500;">docker compose down
$ -weight: 500;">docker compose down
[+] Running 2/2 β Container dtpg Removed β Network dtstack-pg_default Removed
[+] Running 2/2 β Container dtpg Removed β Network dtstack-pg_default Removed
[+] Running 2/2 β Container dtpg Removed β Network dtstack-pg_default Removed
$ cat > .env << EOF
POSTGRES_PASSWORD=-weight: 500;">docker
POSTGRES_DB=testdb
EOF
$ cat > .env << EOF
POSTGRES_PASSWORD=-weight: 500;">docker
POSTGRES_DB=testdb
EOF
$ cat > .env << EOF
POSTGRES_PASSWORD=-weight: 500;">docker
POSTGRES_DB=testdb
EOF
services: dtpg: container_name: dtpg image: postgres:17 environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} volumes: - pgdata:/var/lib/postgresql/data tmpfs: - /var/run/postgresql volumes: pgdata:
services: dtpg: container_name: dtpg image: postgres:17 environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} volumes: - pgdata:/var/lib/postgresql/data tmpfs: - /var/run/postgresql volumes: pgdata:
services: dtpg: container_name: dtpg image: postgres:17 environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} volumes: - pgdata:/var/lib/postgresql/data tmpfs: - /var/run/postgresql volumes: pgdata:
$ -weight: 500;">docker compose down
$ -weight: 500;">docker compose down
$ -weight: 500;">docker compose down
[+] Running 2/2 β Container dtpg Removed β Network dtstack-pg_default Removed
[+] Running 2/2 β Container dtpg Removed β Network dtstack-pg_default Removed
[+] Running 2/2 β Container dtpg Removed β Network dtstack-pg_default Removed
$ -weight: 500;">docker volume ls | grep dtstack
$ -weight: 500;">docker volume ls | grep dtstack
$ -weight: 500;">docker volume ls | grep dtstack
local dtstack-pg_pgdata
local dtstack-pg_pgdata
local dtstack-pg_pgdata
$ -weight: 500;">docker compose down --volumes
$ -weight: 500;">docker compose down --volumes
$ -weight: 500;">docker compose down --volumes
[+] Running 1/1 β Volume dtstack-pg_pgdata Removed
[+] Running 1/1 β Volume dtstack-pg_pgdata Removed
[+] Running 1/1 β Volume dtstack-pg_pgdata Removed
$ mkdir -p dtstack-cb && cd dtstack-cb
$ mkdir -p dtstack-cb && cd dtstack-cb
$ mkdir -p dtstack-cb && cd dtstack-cb
services: cloudbeaver: container_name: cloudbeaver image: dbeaver/cloudbeaver:latest ports: - "8978:8978" volumes: - cbdata:/opt/cloudbeaver/workspace volumes: cbdata:
services: cloudbeaver: container_name: cloudbeaver image: dbeaver/cloudbeaver:latest ports: - "8978:8978" volumes: - cbdata:/opt/cloudbeaver/workspace volumes: cbdata:
services: cloudbeaver: container_name: cloudbeaver image: dbeaver/cloudbeaver:latest ports: - "8978:8978" volumes: - cbdata:/opt/cloudbeaver/workspace volumes: cbdata:
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
[+] Running 3/3 β Network dtstack-cb_default Created β Volume dtstack-cb_cbdata Created β Container cloudbeaver Started
[+] Running 3/3 β Network dtstack-cb_default Created β Volume dtstack-cb_cbdata Created β Container cloudbeaver Started
[+] Running 3/3 β Network dtstack-cb_default Created β Volume dtstack-cb_cbdata Created β Container cloudbeaver Started
$ -weight: 500;">docker compose down --volumes
$ -weight: 500;">docker compose down --volumes
$ -weight: 500;">docker compose down --volumes
$ mkdir -p nc-db && cd nc-db
$ mkdir -p nc-db && cd nc-db
$ mkdir -p nc-db && cd nc-db
$ cat > .env << EOF
MYSQL_ROOT_PASSWORD=nextcloud
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_PASSWORD=nextcloud
EOF
$ cat > .env << EOF
MYSQL_ROOT_PASSWORD=nextcloud
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_PASSWORD=nextcloud
EOF
$ cat > .env << EOF
MYSQL_ROOT_PASSWORD=nextcloud
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_PASSWORD=nextcloud
EOF
services: db: container_name: nc-db image: mariadb:11 ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} volumes: - dbdata:/var/lib/mysql volumes: dbdata:
services: db: container_name: nc-db image: mariadb:11 ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} volumes: - dbdata:/var/lib/mysql volumes: dbdata:
services: db: container_name: nc-db image: mariadb:11 ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} volumes: - dbdata:/var/lib/mysql volumes: dbdata:
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose exec db mariadb -u root -pnextcloud -e "SHOW DATABASES;"
$ -weight: 500;">docker compose exec db mariadb -u root -pnextcloud -e "SHOW DATABASES;"
$ -weight: 500;">docker compose exec db mariadb -u root -pnextcloud -e "SHOW DATABASES;"
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nextcloud |
| performance_schema |
| sys |
+--------------------+
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nextcloud |
| performance_schema |
| sys |
+--------------------+
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nextcloud |
| performance_schema |
| sys |
+--------------------+
$ -weight: 500;">docker compose down --volumes
$ -weight: 500;">docker compose down --volumes
$ -weight: 500;">docker compose down --volumes
$ cd ~
$ mkdir -p nc-redis && cd nc-redis
$ cd ~
$ mkdir -p nc-redis && cd nc-redis
$ cd ~
$ mkdir -p nc-redis && cd nc-redis
services: redis: container_name: nc-redis image: redis:8.6 ports: - "6379:6379" volumes: - redisdata:/data volumes: redisdata:
services: redis: container_name: nc-redis image: redis:8.6 ports: - "6379:6379" volumes: - redisdata:/data volumes: redisdata:
services: redis: container_name: nc-redis image: redis:8.6 ports: - "6379:6379" volumes: - redisdata:/data volumes: redisdata:
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose exec redis redis-cli PING
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose exec redis redis-cli PING
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose exec redis redis-cli PING
$ -weight: 500;">docker compose down --volumes
$ -weight: 500;">docker compose down --volumes
$ -weight: 500;">docker compose down --volumes
$ cd ~
$ mkdir -p nc-php && cd nc-php
$ cd ~
$ mkdir -p nc-php && cd nc-php
$ cd ~
$ mkdir -p nc-php && cd nc-php
services: php: container_name: nc-php image: nextcloud:fpm ports: - "9000:9000" volumes: - ./html:/var/www/html
services: php: container_name: nc-php image: nextcloud:fpm ports: - "9000:9000" volumes: - ./html:/var/www/html
services: php: container_name: nc-php image: nextcloud:fpm ports: - "9000:9000" volumes: - ./html:/var/www/html
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose down
$ -weight: 500;">docker compose down
$ -weight: 500;">docker compose down
$ cd ~
$ mkdir -p nc-nginx && cd nc-nginx
$ cd ~
$ mkdir -p nc-nginx && cd nc-nginx
$ cd ~
$ mkdir -p nc-nginx && cd nc-nginx
services: nginx: container_name: nc-nginx image: nginx:latest ports: - "8080:80" volumes: - ./html:/usr/share/nginx/html
services: nginx: container_name: nc-nginx image: nginx:latest ports: - "8080:80" volumes: - ./html:/usr/share/nginx/html
services: nginx: container_name: nc-nginx image: nginx:latest ports: - "8080:80" volumes: - ./html:/usr/share/nginx/html
$ mkdir -p html
$ cat > html/index.html << 'EOF'
<h2>Nextcloud is coming</h2>
EOF
$ mkdir -p html
$ cat > html/index.html << 'EOF'
<h2>Nextcloud is coming</h2>
EOF
$ mkdir -p html
$ cat > html/index.html << 'EOF'
<h2>Nextcloud is coming</h2>
EOF
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose exec nginx -weight: 500;">curl localhost
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose exec nginx -weight: 500;">curl localhost
$ -weight: 500;">docker compose up -d
$ -weight: 500;">docker compose exec nginx -weight: 500;">curl localhost
$ -weight: 500;">docker compose down
$ -weight: 500;">docker compose down
$ -weight: 500;">docker compose down - The second command is a 150-character wall of flags
- One typo in --tmpfs and PostgreSQL silently starts but won't accept connections
- Forget --network dtstack and the containers won't find each other
- Tear it down and rebuild? Type it all again
- What about when you have 5 containers? 10? - Ep 1-6 completed. Docker is installed and running, you know volumes, networking, and port mapping. Rootless mode recommended.
- Docker Compose plugin. Already installed as part of Blog-01/02. Just run -weight: 500;">docker compose version to verify. - services: is the top-level key. Each entry under services: is one container. We have one, and it's called dtpg.
- container_name gives it a clean name. Instead of Compose's auto-generated dtstack-pg-dtpg-1, we get dtpg. Same as --name in -weight: 500;">docker run.
- No --network flag. The network is implicit. We're not connecting to anything else yet. One container, one -weight: 500;">service.
- Volumes are declared at the bottom. Named volumes are defined in the volumes: block and referenced by the -weight: 500;">service. Docker creates them on first use. - LinkedIn: Share with your network
- Twitter: Tweet about it
- Questions? Drop a comment below or reach out on LinkedIn