0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Docker コマンド メモ

Last updated at Posted at 2021-07-11

python manage.py collectstatic

作成するファイル(3つ)
Dockerfile
requirements.txt
docker-compose.yml

Djangoプロジェクト作成

docker-compose run --rm web django-admin.py startproject mysite .

複数Dockerコンテナを起動

docker-compose up

マイグレーション

$ docker-compose run --rm web python3 manage.py makemigrations

$ docker-compose run --rm web python3 manage.py migrate

dockerビルド

$ docker-compose build

docker実行

$ docker-compose up

コンテナ一覧表示

docker ps -a

コンテナを起動する

$ docker start [コンテナID]

コンテナの削除

$ docker rm [コンテナID]

停止コンテナ一括削除

<=1.12

$ docker rm `docker ps -f "status=exited" -q`
>=1.13

$ docker container prune

docker-compose.ymlの
services:
アプリ名(webなど):

Sudo docker-compose run web python manage.py makemigrations
Sudo docker-compose run web python manage.py migrate

dockerのimage全て削除

docker rmi $(docker images -q) -f

docker 再起動

osascript -e 'quit app "Docker"'

open /Applications/Docker.app

#メモ
dockerを使用し、postgresqlを実装する場合
自身のローカル環境のpostgresqlは停止させること
(brew services stop postgres)
理由は、port5432がpostgresqlとdocker-composeで競合するため

dockerの再起動

sudo launchctl start docker
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?