- Notation
- Useful Commands
- Remove Dangling Images (none:none)
- Remove Stopped Containers
- Change Timezone in Dockerfile
- Uninstall Docker
- Install Docker (Latest Version)
- Open GUI within Docker Container
- Remote Docker Access with TCP for Ubuntu (Not Secure, without TLS)
- Docker Image Save and Load
- Restart Docker Daemon
- Default nvidia runtime
- Install nvidia-docker2 Offline
- Create docker context
- System Space Usage
- Install Docker Compose on Raspbian
- vscode
$
: Host, non root user
#
: Host, root user
(docker)$
: Inside docker container, non root user
(docker)#
: Inside docker container, root user
$ docker rmi -f `docker images -f "dangling=true" -q`
or
$ docker image prune
$ docker rm -f `docker container ps -aq --filter status=exited --filter status=created`
or
$ docker container prune
RUN ln -sf /usr/share/zoneinfo/Turkey /etc/localtime
$ sudo apt-get purge -y docker-engine docker docker.io docker-ce
$ sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce
$ sudo apt-get update && sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable" && \
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io
On the host system run following commands:
$ xhost local:root
$ xhost +local:docker
Run docker container:
Necessary arguments for GUI applications: -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY
$ docker run -it --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY ubuntu
Inside docker container, install and run xeyes for testing.
(docker)# apt update && apt install -y x11-apps
(docker)# xeyes
- Open:
$ sudo vi /lib/systemd/system/docker.service
- Change
ExecStart
Line:
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:4243
- Restart Docker Daemon and Service:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
Disable FIREWALL https://linuxize.com/post/how-to-stop-and-disable-firewalld-on-centos-7/
- Check:
$ sudo docker -H tcp://127.0.0.1:4243 ps
- Save:
$ docker save image_name > image.tar
$ gzip image.tar
- Load:
$ gunzip image.tar.gz
$ docker load < image.tar
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
- Install nvidia-container-runtime
Ubuntu
$ sudo apt-get install nvidia-container-runtime
Centos
$ sudo yum install nvidia-container-runtime
- Edit
/etc/docker/daemon.json
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}
sudo pkill -SIGHUP dockerd
-
Docker version:
18.09.2
-
Download
.zip
file that contains.deb
files from Google Drive and extract it:
https://drive.google.com/file/d/1ihoSEZvQDumYX7P_VxUGmWFeRJn4X3lM/view?usp=sharing
- Run
run.sh
:
$ bash run.sh
- All the
.deb
files are prepared with the following command:
$ apt install apt-transport-https
$ rm -rf /var/cache/apt/archives/*
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
$ apt-get update
$ apt-get install --download-only nvidia-docker2=2.0.3+docker18.09.2-1 nvidia-container-runtime=2.0.0+docker18.09.2-1
.deb
files are stored in/var/cache/apt/archives/
$ docker context create gcp_ssh --docker "host=ssh://myserver"
$ docker system df -v
$ sudo apt-get install libffi-dev libssl-dev
$ sudo apt-get install -y python3-pip
$ sudo apt-get remove python-configparser
$ sudo pip3 install docker-compose
Template: https://github.com/fatihbaltaci/vscode_docker_template
.vscode/settings.json
{
"python.pythonPath": "python",
"python.linting.pylintEnabled": true,
"python.linting.pycodestyleEnabled": false,
"python.linting.enabled": true,
// "docker.host":"ssh://your-remote-user@your-remote-machine-fqdn-or-ip-here",
}
.devcontainer/devcontainer.json
{
"name": "Existing Dockerfile",
"context": "..",
"dockerFile": "../Dockerfile",
// "image": "ubuntu:18.04",
"runArgs": [
"-v", "${env:HOME}${env:USERPROFILE}/.ssh:/root/.ssh-localhost:ro",
"-p", "1414:1414",
],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "pylint",
"python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"]
},
"postCreateCommand": "mkdir -p ~/.ssh && cp -r ~/.ssh-localhost/* ~/.ssh && chmod 700 ~/.ssh && chmod 600 ~/.ssh/*",
"extensions": ["ms-python.python"]
}
unknown flag: --gpus
sudo apt-get install docker-ce-cli