Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions _posts/2022-12-16-dockerfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ services:
devcontainer:
image: mcr.microsoft.com/devcontainers/base:ubuntu
volumes:
- ../..:/workspaces:cached
- ../..:/workspaces
network_mode: service:db
command: sleep infinity

Expand All @@ -89,7 +89,7 @@ volumes:
```

In this example:
- `../..:/workspaces:cached` mounts the workspace folder from the local source tree into the Dev Container.
- `../..:/workspaces` mounts the workspace folder from the local source tree into the Dev Container.
- `network_mode: service:db` puts the Dev Container on the same network as the database, so that it can access it on `localhost`.
- The `db` section uses the [Postgres](https://hub.docker.com/_/postgres) image with a few settings.

Expand All @@ -106,7 +106,7 @@ Next, let's configure devcontainer.json to use it.
In this example:
- `service` indicates which service in the `docker-compose.yml` file is the Dev Container.
- `dockerComposeFile` indicates where to find the `docker-compose.yml` file.
- `workspaceFolder` indicates where to mount the workspace folder. This corresponds to a sub-folder under the mount point from `../..:/workspaces:cached` in the `docker-compose.yml` file.
- `workspaceFolder` indicates where to mount the workspace folder. This corresponds to a sub-folder under the mount point from `../..:/workspaces` in the `docker-compose.yml` file.

That's it!

Expand All @@ -122,7 +122,7 @@ services:
context: .
dockerfile: Dockerfile
volumes:
- ../..:/workspaces:cached
- ../..:/workspaces
network_mode: service:db
command: sleep infinity

Expand Down