简体   繁体   中英

Docker exec command gets failed?

I am new to Docker Concept , I just started today playing with it . And I found out the exec command whose job is to run a new command in a running container.

I am inside ~/linux-tweet-app directory which contains index-original.html and index.html files. My container is running :

 docker container run \
 --detach \
 --publish 80:80 \
 --name linux_tweet_app \
 --mount type=bind,source="$(pwd)",target=/usr/share/nginx/html \
 $DOCKERID/linux_tweet_app:1.0

My task is to copy index-original.html content to index.html . As i am using bind mount on docker host so, this works:

 cp index-new.html index.html

and the changes got reflected ,

But while doing so with exec :

docker exec -it linux_tweet_app cp index-original.html index.html

I got the following error : 在此处输入图片说明

I am not able to understand what is happening? Any help would be appreciated to this newcomer

Thankyou.

It's because you need to use full path inside container, so this should work:

docker exec -it linux_tweet_app cp /usr/share/nginx/html/index-original.html /usr/share/nginx/html/index.html

You may also specify WORKDIR in Dockerfile and set it to /usr/share/nginx/html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM