sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
=============================================================================
curl -fsSL [Link] | sudo apt-key add -
=============================================================================
sudo apt-key fingerprint 0EBFCD88
=============================================================================
sudo add-apt-repository \
"deb [arch=amd64] [Link] \
$(lsb_release -cs) \
stable"
=============================================================================
sudo apt-get update
=============================================================================
sudo apt-get install docker-ce docker-compose
=============================================================================
sudo docker run hello-world
=============================================================================
sudo usermod -a -G docker $USER
// above command will add current user to run docker without sudo, restart pc
required
=============================================================================
To apply the new group membership, log out of the server and back in, or type the
following:
su - ${USER}
Run docker in interative mode
-----------------------------
docker run -t -i --name myfirstcontainer ubuntu /bin/bash
=============================================================================
delete docker container
------------------------
docker rum <name or id>
=============================================================================
delete docker image
------------------------
docker rum <name or id>
=============================================================================
Run docker in daemon mode
-----------------------------
docker run -t -d --name MyDaemon ubuntu /bin/bash
stop running docker
--------------------
docker stop <name or id>
start stopped docker
---------------------
docker start <name or id>
Execute command in docker container using API
-------------------------
docker exec <name or id> <command>
docker exec MyDaemon ls
mount host dir to container
--------------------------------------
docker run -t -v /home/deepak/test1/:/var/www/html/ -d --name MyDaemon ubuntu
/bin/bash
example...
docker run -p 80:80 -v /home/deepak/Documents/docker-test/test1/src/:/var/www/html
hello-world