To run my docker image locally, I use:
docker run --rm -d -p 80:80 mkdocs:latest nginx -g 'daemon off;'
My problem is: When setting up a Google Cloud VM using this docker image (in Artifact Registry), how do I setup the COMMAND/ARG parts? I'm very new to the whole Google Cloud VM and container stuffs.
I read the docker/gcloud docs and looks like everything before the container image name (nginx) is just an OPTION, not a COMMAND or ARG. However the whole thing really confuses me a lot. I tried a few times:
Using the whole
docker run --rm -d -p 80:80 mkdocs:latest nginx -g 'daemon off;'as COMMAND, doesn't workCreating a few ARGs such as
nginx-g 'daemon off;', but then I have no idea how to passmkdocs:latestand-d,-p 80:80to it. Doesn't work anyway.
I also tried to ssh into the VM but it does not connect.
Here is the dockerfile:
# MkDocs container
FROM python:3-alpine AS build-env
RUN apk add bash
RUN apk add --no-cache make cmake
ENV PATH="${PATH}:/usr/src/mkdocs/.local/bin"
RUN pip install --upgrade pip
RUN pip install pymdown-extensions \
&& pip install mkdocs \
&& pip install mkdocs-techdocs-core \
&& pip install mkdocs-material \
&& pip install mkdocs-rtd-dropdown \
&& pip install mkdocs-git-revision-date-plugin \
&& pip install mkdocs-git-revision-date-localized-plugin \
&& pip install mkdocs-redirects \
&& pip install mkdocs-video
ENV PATH="${PATH}:/usr/src/mkdocs/.local/bin"
RUN mkdir -p /home/mkdocs/
WORKDIR /home/mkdocs/
# Added for cloud run
COPY . .
RUN mkdocs build
WORKDIR /
ENTRYPOINT ["/usr/src/mkdocs/.local/bin/mkdocs"]
# Nginx container
FROM nginx:1.21.6-alpine
RUN apk add bash
EXPOSE 80
ENV USER=myuser
ENV UID=7579
ENV GID=7579
RUN addgroup --gid "$GID" "$USER" && adduser --disabled-password --gecos "" --home "$(pwd)" --ingroup "$USER" --no-create-home --uid "$UID" -G "$USER" "$USER"
RUN cat /etc/nginx/nginx.conf
COPY nginx.conf /etc/nginx/nginx.conf
WORKDIR /
RUN mkdir -p /home/mkdocs
COPY --from=build-env /home/mkdocs/site/ /home/mkdocs/
RUN mv /home/mkdocs/* /usr/share/nginx/html/
RUN chown nginx:nginx /usr/share/nginx/html/*
RUN mkdir /tmp/nginx && chown nginx:nginx /tmp/nginx
USER nginx:nginx