How to INSTALL Docker: Linux or Windows (with important analogies) + vnc server with GUI
Docker has changed our lives, we don’t have to deal with system breaks or install specific libraries again and again. Replicating the same stuff to work on another person pc irrespective of Windows, Linux or Mac we can be sure if his/her system can run docker = he definitely can run my project.
But installing docker is tricky, we install it after months or years then we forget how we did it last time and that’s fine. We developers work on a lot — so it's fine to forget some stuff so to capture more and better stuff that we need in daily life.
Okay so for those developers I am putting here the steps to set up docker easily on their system. Original documentation is also there but — phew it's too long to be Read.
So here you go!
You can follow this repo as well for hands-on experience vermavinay982/Docker-Helper-Scripts: Regular docker commands consolidated in one repository. (github.com)
Docker Installation
OR
1. Right Click on This and then click “save link as…”
2. Save the file with the name on your Desktop as “Anything.sh” (Just it should have .sh as extension)
3. Open Terminal on Desktop and do “sudo chmod +x Anything.sh”
4. Now your file is ready to RUN.
5. Simply do “bash Anything.sh” or “./Anything.sh”
For Windows there is Direct Installer for Docker Desktop Start Download for Windows
If want to run docker without “sudo” :P
If want to run docker without using sudo every time — you need to add your user (who has root privileges) to docker group. For this run following command
Error: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker or (logout/login your system)
sudo docker run docker/whalesay cowsay hello-Dev
More Deep Info Here — about using docker w/o sudo
For Windows, adding to user group is a little different than Linux
if you are getting this error then
1. Find your domain/account using "whoami" command in command prompt
2. Open CMD as administrator and type this command
3. Replace {DOMAIN\account} with the result from "whoami"
NET LOCALGROUP "docker-user" "{DOMAIN\account}" /add
You can follow the GUI way
Computer Management -> Local user and Groups -> Groups -> docker-users -> Add -> Enter Domain/Account -> OK -> Sign Out and login again
Analogy to remember order
port -p your's:docker's
volume -v your's:docker's
Few Other Important Common Commands
docker exec -it bash
docker exec -it python3
docker attach mycontainer
docker cp mycontainer:/filename.txt filename.txt# mount current volume, in docker
docker run -it --rm -v $PWD:/work --name=test_mount ubuntu
Saving and Loading Image — Without Internet
docker save -o
docker save --output hello.tar colorapp
docker load --input hello.tar
Run Python with display
docker run --rm -it --env=”DISPLAY” --volume=”$HOME/.Xauthority:/root/.Xauthority:rw” python
That’s it, It was not supposed to be a docker tutorial. It’s more like a cheatsheet that we can refer whenever we install docker. If you would like to add some more feel free to comment down, I will update the document. Docker is fun, its intuitive and major requirement for any company now a days. Sooner or later you have to learn it.
Happy Dockering !!
Just a Bonus tip
# to start the server
docker run -d --name ubvnc -p 6080:80 -p 5900:5900 \
-v /path_to_data:/data \
-v "$(pwd)"/:/workspace \
dorowu/ubuntu-desktop-lxde-vnc:bionic
# to stop
docker stop ubvnc
# to start
docker start ubvnc
Using this, you can access to a complete visual desktop, where you can visualize dataset, videos, and run browser as well. Which is great, you don't need to download dataset to local pc.
You can access the vnc server at — http://127.0.0.1:6080/#/
If not accessible, then you may need to enable tunnelling, that is easy too. if the server is far away — that is ssh with -L argument. Its easy and fun.
ssh -L 6080:localhost:6080 vinay@server_ip