- Fix Docker error: request canceled while waiting for connection
(Source: docker/kitematic#2956)
Go to Docker settings > network > DNS server . change from automaic to fixed ( default is 8.8.8.8 )
- Cannot open localhost
docker run -it -p 8888:8888 image:version
First port: external port. Second port: internal port.
- Kill all running containers
docker kill $(docker ps -q)
- Delete all stopped containers
docker rm $(docker ps -a -q)
- Delete all images
docker rmi -f $(docker images -q)
- Delete all volumes
docker volume prune
- Full system prune
docker system prune -a
- Mount a host directory to a container (Windows)
docker run -v d:/data:/data alpine ls /data
- Access to a container's terminal
docker exec -it container_name /bin/bash
docker exec -it -u root container_name /bin/bash
- Install ping in Docker
apt update
apt install iputils-ping
- Check Ubuntu version inside a Docker container
cat /etc/lsb-release
-
Fix
Error response from daemon: driver failed programming external connectivity on endpoint
error on Windows 10: restart Docker
docker rm $(docker stop $(docker ps -a -q --filter ancestor=<image-name>))
We need to disable drive sharing (and click "Apply") and re-enable it again (and click "Apply").
-
Sometimes (when?), it's necessary to increase the resources allocating to Docker
-
Use bind mount for local development and COPY in production (https://hackernoon.com/how-to-move-code-into-a-docker-container-ab28edcc2901)
Must put schemaVersion: "2.0.0"
in the beginning of a test file.
In the remote machine:
docker run -it -p 8080:8888 -p 6006:6006 -v ~/:/host waleedka/modern-deep-learning
In the local machine:
ssh -N -L localhost:8000:localhost:8080 username@remoteHostIp
-
Use
--rm
flag for short commands and-d
flag for long commands that we want to run in the background -
Run a script inside a Docker container with
bash my_script.sh
, not./my_script.sh
Add --security-opt seccomp=unconfined
flag when creating the container. Only for trusted code of course. Or in desperated situation.
First port: external port.
docker-compose up -d --no-deps --build <service_name>
(Security concern)
docker run -it --security-opt seccomp=unconfined 4oh4/pi
- Detach a Docker container
Ctrl + p then Ctrl + q, then we can safely quit the VM
- Install Docker with Ubuntu dev branch
Must use an older repository and then continue like normal
- Run Jupyter notebook inside Docker: Use [tini][https://github.com/krallin/tini]
In the Dockerfile
# Add Tini. Tini operates as a process subreaper for jupyter. This prevents kernel crashes.
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
RUN chmod +x /usr/bin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
Note: Might need to use sudo
in various command, use pass init
instead of pass git init
, use gpg2
instead of gpg
$ sudo apt install pass # Install Pass
$ gpg --full-generate-key # Create public-private key
$ pass init <public key>
$ mkdir ~/bin; cd ~/bin
$ echo 'export PATH=$PATH:~/bin' >> ~/.bashrc
$ wget https://github.com/docker/docker-credential-helpers/releases/download/v0.6.3/docker-credential-pass-v0.6.3-amd64.tar.gz
$ tar xvzf docker-credential-pass-v0.6.3-amd64.tar.gz
$ chmod a+x docker-credential-pass
$ mkdir ~/.docker
$ echo '{ "credsStore": "pass" }' > ~/.docker/config.json
$ pass insert docker-credential-helpers/docker-pass-initialized-check
$ # Set the password to: pass is initialized
$ docker login # Which will now store credentials in Pass
$ docker pull ubuntu:18.04
- Remove everything in Docker
docker system prune -a
Change the value of the data-root
parameter in /etc/docker/daemon.json
(according to https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file).