{"id":608,"date":"2026-07-24T21:16:26","date_gmt":"2026-07-24T12:16:26","guid":{"rendered":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/608"},"modified":"2026-07-24T21:16:26","modified_gmt":"2026-07-24T12:16:26","slug":"docker%e3%81%ae%e5%9f%ba%e6%9c%ac%e7%9a%84%e3%81%aa%e4%bd%bf%e3%81%84%e6%96%b9%e3%82%ac%e3%82%a4%e3%83%89","status":"publish","type":"post","link":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/608","title":{"rendered":"Docker\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u30ac\u30a4\u30c9"},"content":{"rendered":"<h2>Docker\u3068\u306f<\/h2>\n<p>Docker\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u305d\u306e\u5b9f\u884c\u74b0\u5883\u3092<strong>\u30b3\u30f3\u30c6\u30ca<\/strong>\u3068\u3044\u3046\u5358\u4f4d\u3067\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3057\u3001\u3069\u3053\u3067\u3082\u540c\u3058\u3088\u3046\u306b\u52d5\u4f5c\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002\u4eee\u60f3\u30de\u30b7\u30f3\u3068\u6bd4\u3079\u3066\u8efd\u91cf\u3067\u9ad8\u901f\u306b\u8d77\u52d5\u3067\u304d\u308b\u70b9\u304c\u7279\u5fb4\u3067\u3059\u3002<\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u624b\u9806<\/h2>\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001\u753b\u9762\u306e\u6307\u793a\u306b\u5f93\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u52d5\u4f5c\u78ba\u8a8d\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre><code>docker version<\/code><\/pre>\n<p>\u30d0\u30fc\u30b8\u30e7\u30f3\u60c5\u5831\u304c\u8868\u793a\u3055\u308c\u308c\u3070\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u6210\u529f\u3067\u3059\u3002<\/p>\n<h2>\u521d\u3081\u3066\u306e\u30b3\u30f3\u30c6\u30ca\u5b9f\u884c<\/h2>\n<p>Docker\u306e\u52d5\u4f5c\u78ba\u8a8d\u3068\u3057\u3066\u3001\u516c\u5f0f\u30a4\u30e1\u30fc\u30b8\u306e<code>hello-world<\/code>\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code>docker run --rm hello-world<\/code><\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001Docker\u304c\u6b63\u5e38\u306b\u52d5\u4f5c\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u793a\u3059\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>\u30a4\u30e1\u30fc\u30b8\u306e\u53d6\u5f97\u3068\u7ba1\u7406<\/h2>\n<p>Docker Hub \u306b\u306f\u69d8\u3005\u306a\u30a4\u30e1\u30fc\u30b8\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u691c\u7d22\u3057\u3066\u53d6\u5f97\u3059\u308b\u306b\u306f\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre><code>docker pull nginx<\/code><\/pre>\n<p>\u53d6\u5f97\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4e00\u89a7\u8868\u793a\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>docker images<\/code><\/pre>\n<h2>\u30b3\u30f3\u30c6\u30ca\u306e\u8d77\u52d5\u3068\u64cd\u4f5c<\/h2>\n<p>\u53d6\u5f97\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u304b\u3089\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3059\u308b\u57fa\u672c\u7684\u306a\u30b3\u30de\u30f3\u30c9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li><strong>\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u5b9f\u884c<\/strong>: <code>docker run -d -p 8080:80 nginx<\/code><\/li>\n<li><strong>\u5bfe\u8a71\u7684\u306b\u30b7\u30a7\u30eb\u3092\u8d77\u52d5<\/strong>: <code>docker run -it ubuntu \/bin\/bash<\/code><\/li>\n<\/ul>\n<p>\u8d77\u52d5\u4e2d\u306e\u30b3\u30f3\u30c6\u30ca\u306f\u4ee5\u4e0b\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>docker ps<\/code><\/pre>\n<p>\u505c\u6b62\u3084\u524a\u9664\u306f\u305d\u308c\u305e\u308c\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u505c\u6b62: <code>docker stop \u30b3\u30f3\u30c6\u30caID<\/code><\/li>\n<li>\u524a\u9664: <code>docker rm \u30b3\u30f3\u30c6\u30caID<\/code><\/li>\n<\/ul>\n<h2>Dockerfile\u3067\u30aa\u30ea\u30b8\u30ca\u30eb\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210<\/h2>\n<p>\u81ea\u5206\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u7528\u306b\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u308a\u305f\u3044\u3068\u304d\u306f\u3001<code>Dockerfile<\/code>\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u30b7\u30f3\u30d7\u30eb\u306a\u4f8b\u3067\u3059\u3002<\/p>\n<pre><code>FROM python:3.10-slim\nWORKDIR \/app\nCOPY . \/app\nRUN pip install -r requirements.txt\nCMD [\"python\",\"app.py\"]<\/code><\/pre>\n<p>\u4f5c\u6210\u3057\u305f Dockerfile \u304c\u3042\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u30a4\u30e1\u30fc\u30b8\u3092\u30d3\u30eb\u30c9\u3057\u307e\u3059\u3002<\/p>\n<pre><code>docker build -t my-python-app .<\/code><\/pre>\n<p>\u30d3\u30eb\u30c9\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u5148\u307b\u3069\u3068\u540c\u69d8\u306b\u30b3\u30f3\u30c6\u30ca\u3068\u3057\u3066\u8d77\u52d5\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>docker run -d -p 5000:5000 my-python-app<\/code><\/pre>\n<h2>Docker Compose\u3067\u30de\u30eb\u30c1\u30b3\u30f3\u30c6\u30ca\u74b0\u5883\u3092\u69cb\u7bc9<\/h2>\n<p>\u8907\u6570\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u9023\u643a\u3055\u305b\u308b\u5834\u5408\u306f\u3001<code>docker-compose.yml<\/code>\u3092\u5229\u7528\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306f Web \u30a2\u30d7\u30ea\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u7d44\u307f\u5408\u308f\u305b\u305f\u4f8b\u3067\u3059\u3002<\/p>\n<pre><code>version: \"3\"\nservices:\n  web:\n    build: .\/web\n    ports:\n      - \"8000:8000\"\n    depends_on:\n      - db\n  db:\n    image: postgres:13\n    environment:\n      POSTGRES_USER: user\n      POSTGRES_PASSWORD: password\n      POSTGRES_DB: mydb<\/code><\/pre>\n<p>\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u5b9a\u7fa9\u3055\u308c\u305f\u3059\u3079\u3066\u306e\u30b5\u30fc\u30d3\u30b9\u304c\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre><code>docker compose up -d<\/code><\/pre>\n<p>\u505c\u6b62\u3059\u308b\u5834\u5408\u306f <code>docker compose down<\/code> \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Docker \u306f\u958b\u767a\u304b\u3089\u672c\u756a\u307e\u3067\u4e00\u8cab\u3057\u305f\u74b0\u5883\u3092\u63d0\u4f9b\u3057\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30d7\u30ed\u30a4\u3092\u5927\u5e45\u306b\u7c21\u7565\u5316\u3057\u307e\u3059\u3002\u57fa\u672c\u7684\u306a\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3001\u30a4\u30e1\u30fc\u30b8\u53d6\u5f97\u3001\u30b3\u30f3\u30c6\u30ca\u64cd\u4f5c\u306b\u6163\u308c\u305f\u3089\u3001Dockerfile \u3068 Docker Compose \u3092\u6d3b\u7528\u3057\u3066\u81ea\u5206\u3060\u3051\u306e\u958b\u767a\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker\u3068\u306f Docker\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u305d\u306e\u5b9f\u884c\u74b0\u5883\u3092\u30b3\u30f3\u30c6\u30ca\u3068\u3044\u3046\u5358\u4f4d\u3067\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3057\u3001\u3069\u3053\u3067\u3082\u540c\u3058\u3088\u3046\u306b\u52d5\u4f5c\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002\u4eee\u60f3\u30de\u30b7\u30f3\u3068\u6bd4\u3079\u3066\u8efd\u91cf\u3067\u9ad8\u901f\u306b\u8d77\u52d5\u3067\u304d\u308b\u70b9\u304c\u7279\u5fb4\u3067\u3059\u3002 \u30a4\u30f3\u30b9\u30c8\u30fc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-608","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/comments?post=608"}],"version-history":[{"count":0,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/608\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/media?parent=608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/categories?post=608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/tags?post=608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}