Docker関連

提供: 文具堂 Wiki三昧
ナビゲーションに移動 検索に移動

https://hub.docker.com/

Install: https://get.docker.com/

Overview of Docker Compose: https://docs.docker.com/compose/

Docker Compose file version 3 reference: https://docs.docker.com/compose/compose-file/compose-file-v3/

Dockerfile: https://docs.docker.com/engine/reference/builder/

docker pull nginx
docker pull ruby:3.0.1
docker pull ubuntu:20.04

docker run --name nginx -p 1080:80 nginx
docker run --name nginx -p 1080:80 -d nginx
http://localhost:1080/

docker logs nginx
docker logs -f nginx

docker start nginx
docker stop nginx

docker run -it --name ruby --rm ruby:3.0.1
docker run -it --name ruby --rm ruby:3.0.1 bash

docker run -t --name ruby --rm -d ruby:3.0.1
docker exec -it ruby bash

docker run --name ubuntu -it --rm ubuntu:20.04 bash

docker image ls

docker image inspect nginx
"CMD [\"nginx\" \"-g\" \"daemon off;\"]"

docker ps
docker ps --all

後からポートを設定する

docker container run -p 10080:80 nginx

docker content

docker context create remote --docker host=tcp://192.168.1.100:2375 --default-stack-orchestrator=swarm
docker context ls
docker context use remote
docker context rm remote
docker context use default

docker-compose.yml

version: "3.9"
services:
  db:
    # https://hub.docker.com/_/mariadb
    image: mariadb:10
    volumes:
      - db-data:/var/lib/mysql/data
    ports:
      - "13306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=rootpassword
      - MYSQL_USER=dbuser
      - MYSQL_DATABASE=dbname
      - MYSQL_PASSWORD=dbpassword
volumes:
  db-data: