Difference between revisions of "Docker"
Line 58: | Line 58: | ||
sudo docker stop $(sudo docker ps -a -q) | sudo docker stop $(sudo docker ps -a -q) | ||
sudo docker rm $(sudo docker ps -a -q) | sudo docker rm $(sudo docker ps -a -q) | ||
+ | ``` | ||
+ | ``` | ||
+ | docker update --restart always <container_name> | ||
``` | ``` |
Revision as of 20:55, 20 October 2020
Get started
https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo docker run -dit --network ipvlan1003 --name debian1 debian:buster sudo docker attach debian1
expose port on specific ip address (like in a vlan)
sudo docker run -dit -p 192.168.19.2:8000:22 --name debian2 debian:buster
Binding to specific interface on host
https://docs.docker.com/v17.09/engine/userguide/networking/default_network/binding/
If you want to be more restrictive and only allow container services to be contacted through a specific external interface on the host machine, you have two choices. When you invoke docker run you can use either -p IP:host_port:container_port or -p IP::port to specify the external interface for one particular binding. Or if you always want Docker port forwards to bind to one specific IP address, you can edit your system-wide Docker server settings and add the option --ip=IP_ADDRESS. Remember to restart your Docker server after editing this setting.
experimental
nano /etc/docker/daemon.json
{ "experimental": true }
ZFS Issues
I was using a zfs dataset on pool tank - tank/docker I had issues on Ubuntu 18.04 not importing zfs pool on reboot and instead of using /etc/docker/daemon.json like official docs say, I used /etc/default/docker I edited /etc/default/docker and added line DOCKER_OPTS="--storage-driver=zfs" Booted up fine instead of messing with zfs pool import causing it to fail, probably because /var/lib/docker already was up with something. Maybe this happens on more than just Ubuntu 18.04 LTS. Might be a systemd issue or a systemd on ubuntu 18.04 issue.
command examples after you add DOCKER_OPTS="--storage-driver=zfs" to /etc/default/docker
systemctl stop docker cp -rp /var/lib/docker /var/lib/docker.bkp rm -rf /var/lib/docker zfs create -o mountpoint=/var/lib/docker tank/docker systemctl start docker
Cleanup
sudo docker stop $(sudo docker ps -a -q) sudo docker rm $(sudo docker ps -a -q)
docker update --restart always <container_name>