Docker
Commands
- Logs:
docker logs container - Logs since:
docker logs --since 2m container(2m,5h) - Last logs:
docker logs --tail 100 container - Follow logs:
docker logs --follow --tail 10 container - Info on sizes:
docker system df -v - Show commands inside containers:
docker top container
Build image
Move an image between hosts
Fix network not found on docker compose up
If the network changes and you try to start a container, the container fails with a message similar to the following:
ERROR: for SERVICE Cannot start service SERVICE: Could not attach to network xq8k2g3yn3g15d1tonbmas6b4: rpc error: code = NotFound desc = network xq8k2g3yn3g15d1tonbmas6b4 not found
ERROR: for SERVICE Cannot start service SERVICE: network eqm5t4dml9e05oqyb80lw7b7g not found
Docker compose up will create the network but the new network will have another ID and docker compose will not edit the container to use the new network. So after a docker-compose up -d you have to connect the network to the container.
So first, we make sure it was created.
And add it to the container.
Copy a file from container to the host
Start container in interactive mode
In bash:
In powershell:
In CMD:
Compose
- Rebuild an image
docker-compose up -d --no-deps --build <service_name>
Network definition
Docker may step on 192.168.x.x networks. To avoid it, change the default network address bip and the pool of addresses default-address-pools where base is the whole network size and size is the size of each subnetwork.
/etc/docker/daemon.json
---
{
"bip": "172.16.20.1/16",
"default-address-pools": [
{
"base": "172.17.0.0/16",
"size": 24
}
]
}
Check current configuration with docker info.