Skip to content

python-dev-bsram/docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

docker commands

Command Syntax Description Usage
FROM FROM <image>:<tag> Sets the base image for building your container. Define a starting image, e.g., FROM python:3.9
RUN RUN <command> Executes commands during the build process, creating a new layer. Install dependencies, e.g., RUN apt-get update && apt-get install -y curl
COPY COPY <src> <dest> Copies files or directories from the local filesystem into the container. Add local files, e.g., COPY . /app
ADD ADD <src> <dest> Copies files and supports additional features like URL downloads and auto-extracting archives. Use for archives or URLs, e.g., ADD archive.tar.gz /app/extracted
WORKDIR WORKDIR <path> Sets the working directory for subsequent commands. Define a working directory, e.g., WORKDIR /app
ENV ENV <key>=<value> Sets environment variables in the container. Add environment variables, e.g., ENV PORT=8000
EXPOSE EXPOSE <port> Declares the network ports the container listens on. Inform Docker of port, e.g., EXPOSE 8000
CMD CMD ["executable", "param1", "param2"] Specifies the default command to run when the container starts. Set default process, e.g., CMD ["python", "app.py"]
ENTRYPOINT ENTRYPOINT ["executable", "param1"] Configures the container to run as an executable with fixed command. Define entry command, e.g., ENTRYPOINT ["uvicorn"]
VOLUME VOLUME ["<path>"] Creates a mount point and marks it as holding externally mounted volumes. Use for data persistence, e.g., VOLUME ["/data"]
USER USER <username or UID> Sets the user for executing subsequent commands. Run as non-root, e.g., USER appuser
ARG ARG <name>=<default> Defines variables that users can pass at build-time with --build-arg. Set build args, e.g., ARG ENV=production
ONBUILD ONBUILD <Dockerfile command> Adds a trigger that executes when the image is used as a base for another image. Use for parent images, e.g., ONBUILD RUN apt-get install build-essential
STOPSIGNAL STOPSIGNAL <signal> Sets a system call signal to stop the container. Define stop signal, e.g., STOPSIGNAL SIGTERM
HEALTHCHECK HEALTHCHECK CMD <command> Checks the container's health by running a command at intervals. Set up health checks, e.g., `HEALTHCHECK --interval=30s CMD curl -f http://localhost/
LABEL LABEL <key>=<value> Adds metadata to the image, such as version or description. Organize image info, e.g., LABEL version="1.0" description="FastAPI app"

About

docker tutorial

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published