Skip to content

Commit d2667e5

Browse files
authored
Site/dev: allow overriding the podman/docker binaries detection (apache#2051)
The scripts in the `bin/` directory are built to work with both Docker and podman. There are nuances in how both behave, especially wrt docker/podman-compose. Some local environment specifics require the use of `podman-compose`, others the use of `docker-compose`. The default behavior is to prefer the `podman` and `podman-compose` binaries, if those exist and fall back to `docker` and `docker-compose`. Some setups using podman however require the use of `docker-compose` even if `podman-compose` is installed. This may manifest in an error message stating that `--userns` and `--pod` cannot be used together. In that case create a file `.user-settings` in the `site/` folder and add these two lines: ```bash DOCKER=docker COMPOSE=docker-compose ```
1 parent fb418a2 commit d2667e5

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

site/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# under the License.
1818
#
1919

20+
.user-settings
21+
2022
content/releases/
2123

2224
# Created/generated when running Hugo on the local host

site/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ Then point your browser to http://localhost:1313/
3535
Then edit files from your IDE - you will see the changes in your browser. When changing the site structure,
3636
it is often necessary to restart Hugo - just run `site/bin/run-hugo-in-docker.sh` again.
3737

38+
## Dealing with `--userns and --pod cannot be used together` errors
39+
40+
The scripts in the `bin/` directory are built to work with both Docker and podman. There are nuances in how
41+
both behave, especially wrt docker/podman-compose. Some local environment specifics require the use of
42+
`podman-compose`, others the use of `docker-compose`. The default behavior is to prefer the `podman` and
43+
`podman-compose` binaries, if those exist and fall back to `docker` and `docker-compose`. Some setups using
44+
podman however require the use of `docker-compose` even if `podman-compose` is installed. This may manifest
45+
in an error message stating that `--userns` and `--pod` cannot be used together. In that case create a file
46+
`.user-settings` in the `site/` folder and add these two lines:
47+
```bash
48+
DOCKER=docker
49+
COMPOSE=docker-compose
50+
```
51+
52+
3853
# Building the static site
3954

4055
## Building a static site - served at http://localhost:8080/

site/bin/_hugo-docker-include.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
# under the License.
1818
#
1919

20-
DOCKER="$(which podman > /dev/null && echo podman || echo docker)"
21-
COMPOSE="$(which podman-compose > /dev/null && echo podman-compose || echo docker-compose)"
20+
[[ -f site/.user-settings ]] && . site/.user-settings
21+
22+
[[ -z ${DOCKER} ]] && DOCKER="$(which podman > /dev/null && echo podman || echo docker)"
23+
[[ -z ${COMPOSE} ]] && COMPOSE="$(which podman-compose > /dev/null && echo podman-compose || echo docker-compose)"
2224

2325
# absolute path to the Polaris workspace, for the volume mount
2426
WORKSPACE="$(pwd)"

0 commit comments

Comments
 (0)