Open5
Docker
# Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.8-slim
# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./
# Install production dependencies.
RUN pip install --no-cache-dir -r requirements.txt
# Run the web service on container startup. Here we use the gunicorn
# webserver, with one worker process and 8 threads.
# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available.
# Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling.
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 app:app
gcloud config set project {project}
gcloud artifacts repositories create backend --location=asia-northeast1 --repository-format=docker
gcloud auth configure-docker asia-northeast1-docker.pkg.dev
docker build ./ -t asia-northeast1-docker.pkg.dev/{project}/{ARのリポジトリ名}/{イメージ名} --platform linux/amd64
m1
docker buildx build ./ -t asia-northeast1-docker.pkg.dev/{project}/{ARのリポジトリ名}/{イメージ名} --platform linux/amd64
docker push asia-northeast1-docker.pkg.dev/{project}/{ARのリポジトリ名}/{イメージ名}
poetry export -f requirements.txt --output requirements.txt --without-hashes
docker container run [option] <image> [command]
docker container run \
--name web-server \
--rm \
--detach \
--publish 8080:80 \
nginx:1.21
コンテナはメインプロセスを実行するために起動する
メインプロセスが終了したコンテナは自動で停止する
docker container run \
--name nginx5 \
--rm \
nginx:1.21 \
ls /etc/nginx
docker image build [option] <path>
docker image build \
--tag my-ubuntu:date \
.
docker image build \
--tag my-ubuntu:date \
--file docker/date/Dockerfile \
docker/date
次に <path> ですが、これは COPY で使うファイルを指定するときの相対パスになります。
COPY .vimrc /root/.vimrc の .vimrc は 実行ディレクトリ/<path>/.vimrc として解釈されます。