{"id":311,"date":"2022-02-02T10:58:02","date_gmt":"2022-02-02T10:58:02","guid":{"rendered":"http:\/\/byomkesh.in\/wordpress\/?p=311"},"modified":"2022-02-02T10:58:03","modified_gmt":"2022-02-02T10:58:03","slug":"docker-podman-in-linux","status":"publish","type":"post","link":"http:\/\/byomkesh.in\/wordpress\/docker-podman-in-linux\/","title":{"rendered":"Docker \/ PODMAN in linux"},"content":{"rendered":"\n<p>First installed podman-compose then created docker file with name docker-compose.yml :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3.1'\r\n\r\nservices:\r\n\r\n  wordpress:\r\n    image: wordpress1\n    restart: always\r\n    ports:\r\n      - 8080:80\r\n    environment:\r\n      WORDPRESS_DB_HOST: db\n      WORDPRESS_DB_USER: mydbuser\n      WORDPRESS_DB_PASSWORD: mydbpassword\n      WORDPRESS_DB_NAME: mydb\r\n    volumes:\r\n      - wordpress:\/var\/www\/html\r\n      - logs:\/var\/log\/apache2\r\n\r\n  db:\r\n    image: wordpress1db\r\n    restart: always\r\n    environment:\r\n      MYSQL_DATABASE: mydb\n      MYSQL_USER: mydbuser\n      MYSQL_PASSWORD: mydbpassword\r\n      MYSQL_RANDOM_ROOT_PASSWORD: '1'\r\n    volumes:\r\n      - db:\/var\/lib\/mysql\r\n\r\nvolumes:\r\n  wordpress:\r\n  db:\r\n  logs:\r\n<\/code><\/pre>\n\n\n\n<p>now run :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>podman-compose up -d<\/code><\/pre>\n\n\n\n<p>It will create containers and run webserver at 8080 port.<\/p>\n\n\n\n<p>to stop and remove the containers run <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>podman-compose down<\/code><\/pre>\n\n\n\n<p>The docker file will create containers for webserver from image wordpress1 and container for database server from image wordpress1db, please check and update image name incase of any problem. Also you can commit after any change to webserver \/ mysql configuration to create another image locally.<\/p>\n\n\n\n<p>The running containers will share storage outside the docker for mysql database files(\/var\/lib\/mysql) in named space db and website (\/var\/www\/html) at named space wordpress.  These named spaces can be looked by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># podman volume ls\n\nDRIVER      VOLUME NAME\r\nlocal       fcab36796140245f735851f808b193c38e4771143db12ead1c59ce2b5fa3177e\r\nlocal       WordPress_db\r\nlocal       WordPress_logs\r\nlocal       WordPress_wordpress\r\n<\/code><\/pre>\n\n\n\n<p>now run following to find out the actual location of the volumes<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># podman volume inspect WordPress_db WordPress_wordpress\n&#91;\r\n    {\r\n        \"Name\": \"WordPress_db\",\r\n        \"Driver\": \"local\",\r\n        \"Mountpoint\": \"\/var\/lib\/containers\/storage\/volumes\/WordPress_db\/_data\",\r\n        \"CreatedAt\": \"2022-01-31T18:54:23.157971622+05:30\",\r\n        \"Labels\": {\r\n            \"io.podman.compose.project\": \"WordPress\"\r\n        },\r\n        \"Scope\": \"local\",\r\n        \"Options\": {}\r\n    },\r\n    {\r\n        \"Name\": \"WordPress_wordpress\",\r\n        \"Driver\": \"local\",\r\n        \"Mountpoint\": \"\/var\/lib\/containers\/storage\/volumes\/WordPress_wordpress\/_data\",\r\n        \"CreatedAt\": \"2022-01-31T18:54:19.661705064+05:30\",\r\n        \"Labels\": {\r\n            \"io.podman.compose.project\": \"WordPress\"\r\n        },\r\n        \"Scope\": \"local\",\r\n        \"Options\": {}\r\n    }\r\n]\r\n<\/code><\/pre>\n\n\n\n<p>You can add\/modify webserver files located at \/var\/lib\/containers\/storage\/volumes\/WordPress_wordpress\/_data<\/p>\n\n\n\n<p>To login to any of the containers above first findout the names of containers by running<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>]# podman container ls\r\nCONTAINER ID  IMAGE                   COMMAND               CREATED      STATUS          PORTS                                        NAMES\r\n4f7976ee3529  k8s.gcr.io\/pause:3.5                          4 hours ago  Up 4 hours ago  0.0.0.0:8080->80\/tcp  bca02e003722-infra\r\n171df0e7c268  localhost\/wp1:latest    apache2-foregroun...  4 hours ago  Up 4 hours ago  0.0.0.0:8080->80\/tcp  WordPress_wordpress_1\r\n70c70112d52b  localhost\/wp1db:latest  mysqld                4 hours ago  Up 4 hours ago  0.0.0.0:8080->80\/tcp  WordPress_db_1\r\n<\/code><\/pre>\n\n\n\n<p>the last word in each line is the name i.e.  WordPress_wordpress_1 and WordPress_db_1 are the container names. Now to login to wordpress (webserver) type the following<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># podman exec -ti WordPress_wordpress_1 \/bin\/bash\r\nroot@171df0e7c268:\/var\/www\/html#<\/code><\/pre>\n\n\n\n<p>similarly for the db server type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>podman exec -ti WordPress_db_1 \/bin\/bash\r\nroot@70c70112d52b:\/#<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First installed podman-compose then created docker file with name docker-compose.yml : now run : It will create containers and run webserver at 8080 port. to stop and remove the containers run The docker file will create containers for webserver from image wordpress1 and container for database server from image wordpress1db, please check and update image &hellip; <a href=\"http:\/\/byomkesh.in\/wordpress\/docker-podman-in-linux\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Docker \/ PODMAN in linux<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-311","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":1,"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":312,"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/posts\/311\/revisions\/312"}],"wp:attachment":[{"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/media?parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/categories?post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/byomkesh.in\/wordpress\/wp-json\/wp\/v2\/tags?post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}