/docker

Some useful dockerfiles

Primary LanguageDockerfile

Docker 2023

Each subdirectory holds a different Dockerfile for various builds.

During the build process, the docker image is given the same name as the subdirectory housing the build file.

Build command

cd path-of-subdirectory
../build 

Include option --progress=plain to print verbosely.

Include option --no-cache to clear your local docker build cache.

Run commands

cd path-to-your-files
docker run -it -v /"${PWD}":/home/user/work    docker-image-name

The option -v /"${PWD}":/home/user/work causes your files in the current directory to be mounted at /home/user/work inside the container. Any changes made inside the container will change the files that are outside the container.

The option -it puts you in an interactive tty terminal.

Include option -name container-name to give your container a name

Include option -rm to delete the container upon exit (and start anew the next time).

Include option -u 0 to have root access inside the container

Include option -p port_outside:port_inside for each TCP/IP port that is needed.

Once inside the container, type the following to verify the versions of commands in use:

info

Connecting to a Container with VS Code

https://code.visualstudio.com/docs/devcontainers/attach-container

To attach to a Docker container, either

  • Step 1: Hit F1 by and type Dev Containers: Attach to Running Container... in the Command Palette

image

image

  • or use the Remote Explorer in the Activity Bar and from the Containers view, select the Attach to Container inline action on the container you want to connect to.