I create an Ionic page inside the container using the container shell and I want to obtain the result files outside the container. I have the src/ folder in a docker volume, if I update the code it updates too in the container but not in the opposite direction. How can I obtain the updates that I make inside the container outside of it?
Dockerfile
FROM node:alpine3.16
WORKDIR /project-meals-mobile-frontend/
RUN npm install -g @ionic/[email protected]
RUN npm install
COPY src/ /project-meals-mobile-frontend/src/
EXPOSE 8100
docker-compose.yml
version: '3'
services:
ionic:
container_name: project-meals-ionic
restart: always
build: ./
command:
ionic serve -p=8100 --external
volumes:
- ./src:/app
- ./node_modules/:/node_modules/
ports:
- "8100:8100"
I execute this to go into the container shell:
docker exec -it project-meals-ionic sh
Then I execute the command to generate a page:
ionic generate page schedule
It works if I do an ls
I have the corresponding files:
drwxr-xr-x 1 root root 4096 Jan 5 15:09 .
drwxr-xr-x 1 root root 4096 Jan 4 21:24 ..
-rw-r--r-- 1 root root 637 Jan 5 15:09 app-routing.module.ts
-rw-r--r-- 1 root root 1170 Jan 4 14:28 app.component.html
-rw-r--r-- 1 root root 1939 Jan 4 14:28 app.component.scss
-rw-r--r-- 1 root root 1523 Jan 4 14:28 app.component.spec.ts
-rw-r--r-- 1 root root 703 Jan 4 14:28 app.component.ts
-rw-r--r-- 1 root root 578 Jan 4 14:28 app.module.ts
drwxr-xr-x 2 root root 4096 Jan 4 19:28 folder
drwxr-xr-x 2 root root 4096 Jan 5 15:09 schedule
I need this folder outside the container to edit the code and upload it to git.
CodePudding user response:
you can use docker cp
to copy the files from the container to your host machine.
syntax:
docker cp containerName:/path/to/folder /path/on/host
Official doc: https://docs.docker.com/engine/reference/commandline/cp/
CodePudding user response:
Mi problem was that in the docker-compose.yml
in the volume declaration I have to use the absolute path inside the docker container not the relative path of the WORKDIR
of the Dockerfile
. For now if I create/edit a file inside the container it reflects out the container.
This is the valid docker-compose.yml
code:
volumes:
- ./src:/project-meals-mobile-frontend/src/
- ./node_modules/:/node_modules/