Docker
Images
docker images
Containers
docker container ps
-a stopped containers
Run
docker run <image_id>|<image_repo_name>
-d daemon/detach
-p publish/expose local_port:remote_port
--name <name> alias
Stop
docker stop $(docker ps -a -q)
Start
docker start <container_id>
Shell
docker exec -it <container_id> bash
Memory/CPU
docker stats
Network
docker network create example
docker run -d --net example --name container1 <image>
docker run -d --net example --name container2 <image>
Run host apps within container
Attach host executable to a running container's network namespace:
- Get the pid
ps -ef | grep gafana
sudo nsenter --target [PID] --net /usr/sbin/tcpdump
- As a sidecar:
docker run -it --net container:nginxtest raesene/alpine-containertools /bin/ash
Ubuntu + Docker (Firewall)
sudo ufw allow from 172.0.0.0/8
Access Host from container
Ubuntu
Use 172.17.0.1
Mac?
Use host.docker.internal