Docker does not update volume inside container - docker

Hello I have a docker container running.
I start it with docker-compose and the respective host folder is also mounted as volume
version: '3.3'
services:
web:
build:
context: ./build/docker
dockerfile: Dockerfile
image: php71develop
container_name: AppPortalH3_dev
ports:
- '80:80'
- '443:443'
tty: true
volumes:
- ../AppPortalH3:/var/www/AppPortalH3
- ../ErnSrc:/var/www/ErnSrc
When I modify one file in my editor, outside the container, changes are not been sync inside the container.
I thought that it was a velocity problem but when execute a cat or vim to the file inside the container the file updates inmediatily.
My OS is linux UBUNTU 18.04

Can try use a Bind mount like this
volumes:
- type: bind
source: ../AppPortalH3
target: /var/www/AppPortalH3
- type: bind
source: ../ErnSrc
target: /var/www/ErnSrc

Related

docke named volume doesn't appear

I have the following two docker compose files:
docker-compose.yml :
version: '2.3'
services:
# test11 service
test11:
build: test11/.
image: "test11"
and
docker-compose.yml (file inside the folder named test11 that contains Dockerfile and the following docker-compose ):
version: '2.3'
networks:
citrixhoneypot_local:
services:
# CitrixHoneypot service
test11:
build: .
container_name: test11
restart: always
networks:
- citrixhoneypot_local
ports:
- "443:443"
image: "test11:2006"
# read_only: true
volumes:
- test11:/opt/test11/logs
volumes:
test11:
driver:local
when i run docker-compose up --build for the first file, everything seems ok and the container build and i can run exec -it sh on it and get access.
but the problem is that the volume isn't made in the path
/var/lib/docker/volumes and i can't find it there.
also when i write in /opt/test11/logs from inside the docker container no file is made under /var/lib/docker/volumes .
I tried this with bind path too. same problem with that too.

docker-compose how to persist mongodb-database

I am using docker-compose and here is my docker-compose.yaml file:
version: "3.7"
services:
node:
container_name: my-app
image: my-app
build:
context: ./my-app-directoty
dockerfile: Dockerfile
command: npm run dev
environment:
MONGO_URL: my-database
port: 3000
volumes:
- ./my-app-directory/src:/app/src
- ./my-app-directory/node_modules:/app/node_modules
ports:
- "3000:3000"
networks:
- my-app-network
depends_on:
- my-database
my-database:
container_name: my-database
image: mongo
ports:
- "27017:27017"
networks:
- my-app-network
networks:
my-app-network:
driver: bridge
I expect to find a clear and newly created database each time I run the following command:
docker-compose build
docker-compose up
But this is not the case. When I bring the containers up with docker-compose up, my database has the exact state of the last time I shut it down with docker-compose down command. And since I have not specified a volume prop in my-database object, is this normal behaviour? Does this mean that no other action to persisting database state is required? And can I use this in production if I ever choose to use docker-compose?
The mongo image define the following volumes:
/data/configdb
/data/db
So docker-volume will create and use a unamed volume for data/db.
If you want to have a new one, use:
docker-compose down -v
docker-compose up -d --build
Or use a mount point mounted on the volume location like:
volumes:
- ./db:/data/db:rw
And drop your local db directories when you want to start over.

Docker Windows Containers and NFS Volume

I have successfully created a Windows Docker Image and I can successfully run the container with docker-compose, for full functionality the application expects a folder location to exist, which is currently a NFS attached drive that contains a folder inside it that the application reads and writes to and is also used by other applications.
I have tried to find valid examples and documentation on Docker for Windows, Windows Containers and Docker Compose for Volumes that are NFS.
This is what I am currently trying
version: "3.4"
services:
service:
build:
context: .
dockerfile: ./Dockerfile
image: imageName
ports:
- 8085:80
environment:
-
volumes:
- type: volume
source: nfs_example
target: C:\example
volume:
nocopy: true
volumes:
nfs_example:
driver: local
driver_opts:
type: "nfs"
o: "addr=\\fileserver.domain,nolock,soft,rw"
device: ":\\Shared\\Folder"
The error message I get is:
ERROR: create service_nfs_example: options are not supported on this platform
NFS doesn't work.I solved it using SMB on the host, then mounted that volume.
New-SmbGlobalMapping -RemotePath \\contosofileserver\share1 -Credential Get-Credentials -LocalPath G:
version: "3.4"
services:
service:
build:
context: .
dockerfile: ./Dockerfile
image: imageName
ports:
- 8085:80
environment:
-
volumes:
- type: bind
source: G:\share1
target: C:\inside\container
This microsoft documentation on the windows containers helped me achieve this.

Docker compose-Mount volume on a few containers AND the host

Im trying to share data between a few containers and the host using docker-compose. I have a docker-compose.yml file that looks like this:
version: '3'
services:
base:
container_name: base
build:
context: .
dockerfile: BaseDockerfile
volumes:
- dependencies:/volumes/dependencies
romee:
container_name: romee
build:
context: .
dockerfile: RomeeDockerfile
environment:
- PYTHONPATH=/volumes/base_dependencies/
volumes:
- dependencies:/volumes/base_dependencies
volumes:
dependencies:
Now the volume "dependencies" is shared successfully between the containers, but I want to also share it with the host. How can I do that?
The question is equivalent to how to specify a path of a named volume:
Solution:
volumes:
dependencies:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/abs/path/to/dependencies'
EDIT
The complete flow would be like,
Image: Dependency generator, at build time (docker build), generate dependency to /temp, then at run time (docker run / docker-compose up), cp -pr /temp /dependencies, after that it can exit 0.

Docker container not writing to volume

I want to setup ownCloud with Docker and Docker-Compose. To achieve this I have a docker-compose.yml with 3 containers and their volumes.
version: '2'
services:
nginx:
build: ./nginx
networks:
- frontend
- backend
volumes:
- owncloud:/var/www/html
owncloud:
build: ./owncloud
networks:
- backend
volumes:
- owncloud:/var/www/html
- data:/data
mysql:
build: ./mariadb
volumes:
- mysql:/var/lib/mysql
networks:
- backend
volumes:
owncloud:
driver: local
data:
driver: local
mysql:
driver: local
networks:
frontend:
driver: bridge
backend:
driver: bridge
I also tried it without the data volume. ownCloud could not write to /data or without this volume to /var/www/html/data. The log only shows timestamps whenever I accessed ownCloud. Changing from data:/data to a hosted volume /var/ownclouddata:/data results in no difference.
The Dockerfiles have only one line each: FROM:image
I´ve tried adding RUN mkdir /data, but it didn´t fix anything.
You need to mount the volumes in the Dockerfile something like this.
VOLUME /data
Later in your docker-compose file, you can either use a named volume like you did earlier or simply use it like this.
/mnt/test:/data
Here /mnt/test is your host volume path and /data is your docker container path.
Hope it helps!

Resources