Jason Rowe

Be curious! Choose your own adventure.

Common Docker Stuff

The following is a list of Docker commands I use. These commands are used on windows 10 running Linux containers.

Connectivity Tests

Frequently I do quick tests to check permissions or connectivity to a service or NFS share from a container. I do this by running a busybox container to perform a simple action. The following is an example of checking connectivity to a mounted NFS drive.

docker run -d -it  --name mounttest --mount type=bind,source=/tmp/exmample,target=/tmp/example busybox:latest

Then connect to the running container to test folder permissions

docker exec -it mounttest sh

Another example to check network connectivity from a container to another endpoint.

docker run  --name networktest busybox:latest ping google.com

Infrastructure

Create an instance of RabbitMQ for local development.

docker run -d -h rabbitserver -p 15672:15672 -p 5672:5672 -p 5671:5671 rabbitmq:3-management

Deploy Portainer to visualize docker locally.

docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v C:\ProgramData\Portainer:/data portainer/portainer

Run a S3 compatible file server.

docker run -p 9000:9000 --name minio1 -e "MINIO_ACCESS_KEY=accesskey" -e "MINIO_SECRET_KEY=secret" minio/minio server /data

Test a build file:

Multipart docker file example and build script.

docker build . -f build/MyApp.Dockerfile

Misc

Copy something from a container.

docs
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-

docker cp mycontainer:/tmp/foo/bar.txt .

Docker file example to build a container without using root.

FROM centos:latest
RUN useradd -r -u 1000 appuser
USER appuser
ENTRYPOINT ["/bin/bash"]

Simple static file server

docker run --user 1000:1000 -d -v /tmp/foldertoserve:/web -p 8080:8080 halverneus/static-file-server:latest

Clean up

If your local docker containers start shutting down or not working reliably you might be running out of docker disk space try the following:

docker system df
docker system prune -a --volumes

Will require downloading images again so don’t do it without reliable internet.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *