Log in to a container
sudo docker exec -it mycontainer bash
sudo docker exec -it mycontainer /bin/bash
Stop/Stop/Status
sudo docker container start mycontainer
sudo docker container stop mycontainer
sudo docker restart mycontainer
sudo docker inspect mycontainer
Pull and specify architecture
sudo docker pull --platform linux/amd64 mycontainer
Remove
sudo docker contaienr ls
sudo docker container rm mycontainer
sudo docker image ls
sudo docker image rm myimagehash
Publish
sudo docker login
sudo docker build -t ghcr.io/org-name/mycontainer:1.0.5 --build-arg USER=user --build-arg PASS=token .
Logs
sudo docker logs --tail 10 mycontainer
Compose
sudo docker-compose down
sudo docker-compose up -d
Tricks
# Show mounted volumes
sudo docker inspect -f '{{ .Mounts }}' edge-core-techconsole
Troubleshooting
# Error: error while loading shared libraries: libz.so.1: failed to map segment from shared object
sudo mount /tmp -o remount,exec
Docker Contexts https://docs.docker.com/engine/reference/commandline/context/
# Create a context pointed at a remote server
docker context create remote-host --docker host=tcp:///my-remote-host:2735,key=key-file
# Change host URL
docker context update --docker "host=tcp://192.168.0.0,key=key-file" remote-host
Note:
key-file
is the name of the file located in the~/.ssh/
folder.
# Change context description
docker context update --description "description of context" remote-host