λ沢.dev

lambdasawa.dev


Project maintained by lambdasawa Hosted on GitHub Pages — Theme by mattgraham

Docker

Dockerfile

docker-compose.yml

wait

MySQL

$ cat schema.sql
USE demo;
CREATE TABLE users (
  id bigint PRIMARY KEY
);

$ docker run \
    -itd \
    -p 3306:3306 \
    -v $PWD:/docker-entrypoint-initdb.d/ \
    -e MYSQL_ROOT_PASSWORD=root \
    -e MYSQL_DATABASE=demo \
    mysql:8.0

$ mysql -uroot -proot -h127.0.0.1 -P3306 -e 'use demo; show tables;'

PostgreSQL

$ docker run \
    -itd \
    -p 5432:5432 \
    -e POSTGRES_PASSWORD=postgres \
    -e POSTGRES_DB=demo \
    postgres:15.0

$ psql postgresql://postgres:postgres@127.0.0.1:5432/diesel_demo -c 'CREATE TABLE posts (id SERIAL PRIMARY KEY)'

Redis

LocalStack

$ cat init_bucket.sh
set -xeu

export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test
aws --endpoint http://127.0.0.1:4566 s3 mb s3://test

$ docker run \
    -itd \
    -p 4566:4566 \
    -p 4571:4571 \
    -v $PWD:/docker-entrypoint-initaws.d/ \
    localstack/localstack

$ env \
    AWS_ACCESS_KEY_ID=test \
    AWS_SECRET_ACCESS_KEY=test \
    aws --endpoint http://127.0.0.1:4566 s3 ls

MinIO

$ docker run \
    -itd \
    -p 9000:9000 \
    -p 9001:9001 \
    -e MINIO_ACCESS_KEY=miniokey \
    -e MINIO_SECRET_KEY=miniokey \
    minio/minio server /data --console-address ":9001"

$ export AWS_ACCESS_KEY_ID=miniokey
$ export AWS_SECRET_ACCESS_KEY=miniokey

$ aws --endpoint http://127.0.0.1:9000 s3 mb s3://test
$ aws --endpoint http://127.0.0.1:9000 s3 ls
2022-03-19 22:10:25 test

Elasticsearch

$ docker run \
  -itd \
  -p 9200:9200 \
  -p 9300:9300 \
  -e "discovery.type=single-node" \
  docker.elastic.co/elasticsearch/elasticsearch:7.17.1

$ curl -X PUT localhost:9200/foo

MailHog

プラットフォームを指定して docker-compose.yml に書かれているイメージを全てダウンロード

for image in (cat docker-compose.yml | jc --yaml | jq -r '.[0] | .services[] | .image' | grep -v null); docker pull --platform linux/amd64 $image; end

Other

https://github.com/abiosoft/colima