{"id":3288,"date":"2016-08-17T15:26:12","date_gmt":"2016-08-17T13:26:12","guid":{"rendered":"https:\/\/adrhc.go.ro\/wordpress\/?p=3288"},"modified":"2019-10-27T13:39:00","modified_gmt":"2019-10-27T11:39:00","slug":"docker","status":"publish","type":"post","link":"https:\/\/adrhc.go.ro\/blog\/docker\/","title":{"rendered":"Docker"},"content":{"rendered":"<p><a href=\"https:\/\/medium.com\/@Grigorkh\/how-to-install-docker-on-ubuntu-19-04-7ccfeda5935\" rel=\"noopener noreferrer\" target=\"_blank\">How To Install Docker on Ubuntu 19.04<\/a><br \/>\n<a href=\"https:\/\/github.com\/docker\/kitematic\/wiki\/Early-Linux-Development\" rel=\"noopener noreferrer\" target=\"_blank\">Kitematic which provide a GUI to the users<\/a><\/p>\n<p><strong>avoid typing sudo whenever you run the docker command<\/strong><br \/>\n<code>sudo usermod -aG docker ${USER}<\/code><\/p>\n<pre class=\"brush:bash shell;toolbar: false\">\r\n# check service status\r\nsudo systemctl status docker\r\n# pull and run an image\r\ndocker run hello-world\r\ndocker run -itP centos cat \/etc\/redhat-release\r\n# lists all the images on your local system\r\ndocker images --help\r\ndocker images\r\n# show all containers on the system\r\ndocker ps --help\r\ndocker ps -a\r\ndocker ps --no-trunc -a\r\n# log into the Docker Hub\r\ndocker login --username=yourhubusername\r\n# removing containers\r\ndocker ps -a\r\ndocker rm --help\r\ndocker rm 6075298d5896\r\n# modify an image\r\ndocker run -itP -v \"$HOME\/KIT\":\/adrhc\/KIT -v \/home\/adrk\/certs\/:\/adrhc\/certs centos \/bin\/bash\r\ncd root\r\nyum -y update\r\nyum install -y wget\r\nwget https:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-7.noarch.rpm\r\nyum localinstall -y epel-release-latest-7.noarch.rpm\r\nyum -y update\r\nyum install -y nano mlocate zip unzip iftop htop net-tools openssh-clients openssh-server which sysvinit-tools psmisc less man-db openssl davfs2 fuse\r\n# configure sshd\r\nsed -i s\/\"#Port 22\"\/\"Port 322\"\/ \/etc\/ssh\/sshd_config\r\n# if you want to change the port on a SELinux system, you have to tell SELinux about this change:\r\nsemanage port -a -t ssh_port_t -p tcp 322\r\n# solving ERROR: Could not load host key: \/etc\/ssh\/ssh_host_rsa_key\r\n\/usr\/bin\/ssh-keygen -A\r\n\/usr\/sbin\/sshd\r\nnetstat -tulpn\r\nCTRL+D\r\n# committing d513e8dff620 container to a new named adrhc\/centos7:v2 image:\r\ndocker commit -m \"CentOS + epel\" -a \"adrhc\" d513e8dff620 adrhc\/centos7:v2\r\n# or commit using the container's name (gloomy_goldstine) to a new named adrhc\/centos7:v2 image:\r\ndocker commit -m \"CentOS + epel\" -a \"adrhc\" gloomy_goldstine adrhc\/centos7:v2\r\n# or commit last created container to a new named adrhc\/centos7:v2 image:\r\ndocker commit -m \"CentOS + epel\" -a \"adrhc\" `docker ps -lq` adrhc\/centos7:v2\r\n# push an image to Docker Hub (see it at https:\/\/cloud.docker.com\/_\/repository\/list)\r\ndocker push adrhc\/centos7\r\n# run the above commited image:\r\ndocker run -itP -v \"$HOME\/KIT\":\/adrhc\/KIT -v \/home\/adrk\/certs\/:\/adrhc\/certs adrhc\/centos7:v2 \/bin\/bash -> will create the container 3a63cfee66f4\r\n# renaming 3a63cfee66f4 container created above\r\ndocker ps -a | grep 3a63cfee66f4\r\ndocker rename 3a63cfee66f4 my_centos7\r\n# or rename last created container:\r\ndocker rename `docker ps -lq` my_centos7\r\n# re-running the container 3a63cfee66f4\r\ndocker start 3a63cfee66f4\r\ndocker start my_centos7\r\n# connecting to\/bringing to front the running container\r\ndocker attach 3a63cfee66f4\r\ndocker attach my_centos7\r\n# detach (see https:\/\/groups.google.com\/forum\/#!msg\/docker-user\/nWXAnyLP9-M\/kbv-FZpF4rUJ)\r\ndocker run -i -t \u2192 can be detached with ^P^Q and reattached with docker attach\r\ndocker run -i \u2192 cannot be detached with ^P^Q; will disrupt stdin\r\ndocker run \u2192 cannot be detached with ^P^Q; can SIGKILL client; can reattach with docker attach\r\n# stopping a running container\r\ndocker stop my_centos7\r\n# get the IP address of the running my_centos7 container\r\ndocker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my_centos7\r\n# remove container\r\ndocker rm 3a63cfee66f4\r\n# or by name\r\ndocker rm my_centos7\r\n# remove image\r\ndocker images; docker ps -a\r\ndocker rmi 143d6907480f\r\ndocker rmi -f 143d6907480f -> removes related containers too\r\n# connect using ssh to the container named my_centos7\r\n# make sure the container exposes desired ports (https:\/\/docs.docker.com\/engine\/reference\/commandline\/run\/)\r\nssh -p 322 root@`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my_centos7`\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n<div class=\"link-more\"><a href=\"https:\/\/adrhc.go.ro\/blog\/docker\/#more-3288\" class=\"more-link\">Continue reading &#10142; <span class=\"screen-reader-text\">Docker<\/span><\/a><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,8,11],"tags":[],"class_list":["post-3288","post","type-post","status-publish","format-standard","hentry","category-commands","category-howto","category-linux"],"_links":{"self":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/3288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/comments?post=3288"}],"version-history":[{"count":0,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/3288\/revisions"}],"wp:attachment":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/media?parent=3288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/categories?post=3288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/tags?post=3288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}