Skip to content

Commit

Permalink
DRIVERS-3041 Prefer podman for container usage (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Nov 15, 2024
1 parent 99f4d6f commit 1a8dce7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ buildvariants:
display_name: Docker
run_on:
- ubuntu2204-small
- macos-14
tasks:
- ".docker" # Run all tasks with the "docker" tag

Expand Down
21 changes: 10 additions & 11 deletions .evergreen/docker/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Drivers Evergreen Tools Dockerfile

The `Dockerfile` and scripts can be used to run a local server in docker container.
The `Dockerfile` and scripts can be used to run a local server in a container.

Additionally, you can build a Docker [container](#driver-testing-using-this-docker-container)
Additionally, you can build a [container](#driver-testing-using-this-container)
for your Driver that shares the binary files and communicates with this container.

You will need Docker (or podman aliased to Docker) installed and running
locally.
You will need podman (or Docker) installed and running locally.

# Run Local Server

Expand All @@ -16,11 +15,11 @@ To run a local server, change to this directory and run:
bash ./run-server.sh
```

This will build the docker image and run it with appropriate settings.
This will build the container image and run it with appropriate settings.
Note that any of the environment variables used by `run-orchestration`
will be passed through to the container.
The appropriate port(s) will be exposed, allowing you to run local test against
the running docker container.
the running container.

The default image can be overridden with `IMAGE`, and the entrypoint with `ENTRYPOINT`.
To use a specific architecture, use `PLATFORM`, e.g. `--platform linux/amd64`.
Expand Down Expand Up @@ -61,20 +60,20 @@ ARCH=amd64 TOPOLOGY=sharded_cluster MONGODB_VERSION=3.6 TARGET_IMAGE=ubuntu18.04

### Get Logs

The orchestration logs can be found using `docker logs`:
The orchestration logs can be found using `podman logs`:

```bash
docker logs mongodb
podman logs mongodb
```

The server logs can be found on the container in /tmp, with the scheme `/tmp/mongo-<port>/mongo.log`.
You can pull them locally using `docker cp`:
You can pull them locally using `podman cp`:

```bash
docker cp mongodb:/tmp/mongo-27017/mongod.log mongod.log
podman cp mongodb:/tmp/mongo-27017/mongod.log mongod.log
```

## Driver Testing using this Docker container
## Driver Testing using this container

First, start this container with the appropriate environment variables, running as:

Expand Down
17 changes: 13 additions & 4 deletions .evergreen/docker/run-server.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Run a local MongoDB orchestration inside a docker container
# Run a local MongoDB orchestration inside a container
#
set -eu

Expand All @@ -18,9 +18,18 @@ if [[ -z $PLATFORM && -n $ARCH ]]; then
PLATFORM="--platform linux/$ARCH"
fi

if command -v podman &> /dev/null; then
DOCKER=podman
else
DOCKER=docker
fi
if [ -n "${DOCKER_COMMAND:-}" ]; then
DOCKER=$DOCKER_COMMAND
fi

pushd $SCRIPT_DIR
USER="--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)"
docker build $PLATFORM -t $NAME $USER $IMAGE
$DOCKER build $PLATFORM -t $NAME $USER $IMAGE
popd
pushd $DRIVERS_TOOLS

Expand Down Expand Up @@ -71,7 +80,7 @@ test -t 1 && ARGS+=" -t"
# Map in the DRIVERS_TOOLS directory.
ARGS+=" -v `pwd`:/root/drivers-evergreen-tools"

# Launch server docker container.
docker run $ARGS $NAME $ENTRYPOINT
# Launch server container.
$DOCKER run $ARGS $NAME $ENTRYPOINT

popd

0 comments on commit 1a8dce7

Please sign in to comment.