How To Install Docker on Ubuntu 19.04 Kitematic which provide a GUI to the users
avoid typing sudo whenever you run the docker command
sudo usermod -aG docker ${USER}
# check service status sudo systemctl status docker # pull and run an image docker run hello-world docker run -itP centos cat /etc/redhat-release # lists all the images on your local system docker images --help docker images # show all containers on the system docker ps --help docker ps -a docker ps --no-trunc -a # log into the Docker Hub docker login --username=yourhubusername # removing containers docker ps -a docker rm --help docker rm 6075298d5896 # modify an image docker run -itP -v "$HOME/KIT":/adrhc/KIT -v /home/adrk/certs/:/adrhc/certs centos /bin/bash cd root yum -y update yum install -y wget wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum localinstall -y epel-release-latest-7.noarch.rpm yum -y update yum install -y nano mlocate zip unzip iftop htop net-tools openssh-clients openssh-server which sysvinit-tools psmisc less man-db openssl davfs2 fuse # configure sshd sed -i s/"#Port 22"/"Port 322"/ /etc/ssh/sshd_config # if you want to change the port on a SELinux system, you have to tell SELinux about this change: semanage port -a -t ssh_port_t -p tcp 322 # solving ERROR: Could not load host key: /etc/ssh/ssh_host_rsa_key /usr/bin/ssh-keygen -A /usr/sbin/sshd netstat -tulpn CTRL+D # committing d513e8dff620 container to a new named adrhc/centos7:v2 image: docker commit -m "CentOS + epel" -a "adrhc" d513e8dff620 adrhc/centos7:v2 # or commit using the container's name (gloomy_goldstine) to a new named adrhc/centos7:v2 image: docker commit -m "CentOS + epel" -a "adrhc" gloomy_goldstine adrhc/centos7:v2 # or commit last created container to a new named adrhc/centos7:v2 image: docker commit -m "CentOS + epel" -a "adrhc" `docker ps -lq` adrhc/centos7:v2 # push an image to Docker Hub (see it at https://cloud.docker.com/_/repository/list) docker push adrhc/centos7 # run the above commited image: docker run -itP -v "$HOME/KIT":/adrhc/KIT -v /home/adrk/certs/:/adrhc/certs adrhc/centos7:v2 /bin/bash -> will create the container 3a63cfee66f4 # renaming 3a63cfee66f4 container created above docker ps -a | grep 3a63cfee66f4 docker rename 3a63cfee66f4 my_centos7 # or rename last created container: docker rename `docker ps -lq` my_centos7 # re-running the container 3a63cfee66f4 docker start 3a63cfee66f4 docker start my_centos7 # connecting to/bringing to front the running container docker attach 3a63cfee66f4 docker attach my_centos7 # detach (see https://groups.google.com/forum/#!msg/docker-user/nWXAnyLP9-M/kbv-FZpF4rUJ) docker run -i -t → can be detached with ^P^Q and reattached with docker attach docker run -i → cannot be detached with ^P^Q; will disrupt stdin docker run → cannot be detached with ^P^Q; can SIGKILL client; can reattach with docker attach # stopping a running container docker stop my_centos7 # get the IP address of the running my_centos7 container docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my_centos7 # remove container docker rm 3a63cfee66f4 # or by name docker rm my_centos7 # remove image docker images; docker ps -a docker rmi 143d6907480f docker rmi -f 143d6907480f -> removes related containers too # connect using ssh to the container named my_centos7 # make sure the container exposes desired ports (https://docs.docker.com/engine/reference/commandline/run/) ssh -p 322 root@`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my_centos7`