RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*
RUN useradd -m user && \
echo "user ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
chmod 0400 /etc/sudoers.d/gitlab
USER userDocuments:
- https://docs.docker.com/engine/reference/commandline/save/
- https://docs.docker.com/engine/reference/commandline/load/
Save one or more images to a tar archive (streamed to STDOUT by default)
$ docker save -o etcd_v3.2.9.tar gcr.io/etcd-development/etcd:v3.2.9$ docker load -i etcd_v3.2.9.tarIt is very useful when docker pull command hangs downloading image
# base image
FROM microsoft/dotnet:2.1-runtime AS base
WORKDIR /app
EXPOSE 80
# build image
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY . .
# `dotnet publish` command will run `dotnet restore` and `dotnet build` implicitly
RUN dotnet publish -c Release -o /app
# Add the binary files that generated in the `build image` container above
FROM base as final
WORKDIR /app
COPY --from=build /app .
RUN ls -al
ENTRYPOINT ["dotnet", "OrleansSilo.dll"]Dockerfile:
FROM ubuntu
ARG MESSAGE
RUN echo $MESSAGECommand:
$ docker build --build-arg MESSAGE=hello .ARG <name>[=<default value>]
You can use an
ARGor anENVinstruction to specify variables that are available to theRUNinstruction. Environment variables defined using theENVinstruction always override anARGinstruction of the same name. Consider this Dockerfile with anENVandARGinstruction.
Dockerfile:
FROM ubuntu
ARG CONT_IMG_VER
ENV CONT_IMG_VER v1.0.0
RUN echo $CONT_IMG_VERCommand:
$ docker build --build-arg CONT_IMG_VER=v2.0.1 .In this case, the
RUNinstruction usesv1.0.0instead of theARGsetting passed by the user:v2.0.1
references: