Updated: 13 February 2025
At the time or writing I cannot find a simple way of running my Docker Compose project on Azure. Some option:
Freelance software engineer United Kingdom
Updated: 13 February 2025
At the time or writing I cannot find a simple way of running my Docker Compose project on Azure. Some option:
Updated: 28 June 2024
Copy file or directory from container to host
docker cp <:containerId>:/file/path/within/container /host/path/target
Copy file or directory from host to container
docker cp /host/path/target <:containerId>:/file/path/within/container
Updated: 08 May 2023
Run an init
inside a container which forwards signals and reaps processes. Configure in a Dockerfile
FROM mcr.microsoft.com/dotnet/sdk
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
tini \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["/usr/bin/tini", "--"]
or docker-compose.yml
services:
web:
image: alpine:latest
init: true
https://github.com/krallin/tini
Tini is the simplest init you could think of. All Tini does is spawn a single child (Tini is meant to be run in a container), and wait for it to exit all the while reaping zombies and performing signal forwarding.
Updated: 23 June 2023
Compose file version 3 reference
Start just one service
docker compose up -d start_me
List containers in json format
docker compose ps --format json | jq .
Updated: 18 August 2023
A smarter Dockerfile linter that helps you build best practice Docker images. The linter parses the Dockerfile into an AST and performs rules on top of the AST. It stands on the shoulders of ShellCheck to lint the Bash code inside
RUN
instructions.
Use online at https://hadolint.github.io/hadolint
Run in a Docker container
docker run --rm -i hadolint/hadolint < Dockerfile
Updated: 27 March 2024
On Linux, IP address of the Docker host
172.17.0.1
Get the IP address of a running container
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' id-or-name
Updated: 16 November 2023
View and follow container logs
sudo docker logs -f my-symf
View container logs via docker compose
docker compose logs certbot
docker compose logs --follow --timestamps --tail="all" <service>
Updated: 01 July 2024
https://docs.docker.com/storage/volumes/
List all docker volumes
docker volume ls
Inspect a volume
docker volume inspect my-vol
[
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/my-vol/_data",
"Name": "my-vol",
"Options": {},
"Scope": "local"
}
]
Delete a volume
docker volume rm my-vol
Delete all volumes
docker volume rm $(docker volume ls -q)
List volumes for a container
docker inspect -f '{{ .Mounts }}' containerid
Remove local and anonymous volumes not referenced by any containers
docker volume prune
Updated: 28 August 2024
Build and tag an image from a Dockerfile in the same directory
docker build -t node-demo .
Start a container
docker run -i -t ubuntu /bin/bash
docker run -it node:19 /bin/bash
docker run -it --rm -d -p 8080:80 --name web nginx
Docker compose
docker-compose up --build
docker-compose up --remove-orphans -d
Stop all containers
docker stop $(docker ps -aq)
List images
docker images
See which containers are running
docker ps
See all containers, including non-running
docker ps -a
Run a php script inside a container
docker run --rm -v $(pwd):/app -w /app php:cli php hello.php
Get ip address of container
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container name>
sudo docker inspect <container name> | grep IPAddress
Command prompt into a container
sudo docker exec -it bash
sudo docker exec -it wp-local-docker_phpfpm_1 /bin/sh -c "[ -e /bin/bash ] && /bin/bash || /bin/sh"
docker-compose exec --user www-data phpfpm bash
Keep a container running. From docker-compose.yml
services:
myservice:
command: bash -c "while true; do echo 'sleeping...' && sleep 10; done"
Remove all stopped containers
docker container prune
Remove all containers
docker rm $(docker ps -aq)
Delete all images
sudo docker rmi $(sudo docker images -q) --force
Remove stopped containers and images, including unused and dangling images
docker system prune -a
Updated: 16 November 2023
phpMyAdmin is available as a Docker image. The MySQL server connection parameters are provided when the container is instantiated.
For a remote MySQL server
docker run --name myadmin \
-e PMA_HOST=https://example.com \
-e PMA_PORT=3306 \
-e PMA_USER=user \
-e PMA_PASSWORD=password \
-p 8080:80 \
phpmyadmin/phpmyadmin
Browse to phpMyAdmin at http://localhost:8080
MySQL server running in a local Docker network some-network
docker run --name myadmin \
--network=some-network \
-e PMA_HOST=db \
-e PMA_PORT=3306 \
-p 8080:80 \
phpmyadmin/phpmyadmin
--network
The docker network the phpMyAdmin container will join.