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?

コンテナ上のファイルを残して、ローカルのディレクトリをマウントする方法

Last updated at Posted at 2024-08-21
IMAGE_TAG=your-image
CONTAINER_NAME=your-container
WORKDIR=/app

sudo docker image build -t $IMAGE_TAG . > build.log 2>&1

sudo docker container run -d --name $CONTAINER_NAME $IMAGE_TAG  
sudo docker container stop $CONTAINER_NAME
sudo docker container cp $CONTAINER_NAME:$WORKDIR/. .
sudo docker container rm $CONTAINER_NAME
sudo chown -R $(whoami):$(whoami) .


sudo docker container run -v $(pwd):$WORKDIR $IMAGE_TAG
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?