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.
Related
Does anyone know how to mount an NFS to a docker container using docker compose? I keep getting the same error each time I run 'docker compose up':
Error response from daemon: error while mounting volume '/var/lib/docker/volumes/test_data/_data': failed to mount local volume: mount /etc/hapee-2.2/certs:/var/lib/docker/volumes/test_data/_data, data: addr=10.15.50.27,nolock,soft: invalid argument
Exports file from the NFS appears to be set up correctly. I've tried deleting '/home/' from the file path as well. IP address is redacted.
/etc/hapee-2.2/certs <ipaddressofpc>(rw,sync,no_subtree_check,no_root_squash)
I keep suspecting the docker-compose.yml, but I'm not sure what the issue with it would be
version: '3.7'
services:
hapee:
image: haproxy:2.2
container_name: test
restart: always
ports:
- "80:80"
- "443:443"
- "8888:8888"
volumes:
- data:/etc/hapee-2.2/certs
logging:
options:
max-size: 100m
max-file: "3"
volumes:
data:
driver_opts:
type: "nfs"
o: "addr=10.15.50.27,nolock,soft,ro"
device: "/etc/hapee-2.2/certs"
Alternatively, does anyone know another method of mounting SSL certificates to an HA Proxy container with docker compose?
Thanks!
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
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.
I am trying to use the following docker-stack.yml file to deploy my services to my Docker Swarm version 17.06-ce. I want to use volumes to map the C:/logs directory on my Windows host machine to the /var/log directory inside my container.
version: '3.3'
services:
myapi:
image: mydomain/myimage
ports:
- "5000:80"
volumes:
- "c:/logs:/var/log/bridge"
When I remove the volumes section, my containers start fine. After adding the volume, the container never even attempts to start i.e.
docker container ps --all does not show my container.
docker events does not show the container trying to start.
The following command works for me, so I know that my syntax is correct:
docker run -it -v "c:/logs:/var/log/bridge" alpine
I've read the volumes documentation a few times now. Is the syntax for my volume correct? Is this a supported scenario? Is this a Docker bug?
Docker run will work when you run it in version 2 and with docker-compose we can run the custom volume mounting.
In version three we have to use the named volumes with default volume path or custom path.
Here is the docker-compose with default volume
version: "3.3"
services:
mysql:
image: mysql
volumes:
- db-data:/var/lib/mysql/data
networks:
- overlay
deploy:
mode: replicated
replicas: 2
endpoint_mode: dnsrr
volumes:
db-data:
volume is mounted to default /var/lib/docker/volumes/repo/_data
We have option to mount the custom path to the volume
version: "3.3"
services:
mysql:
image: mysql
volumes:
- db-data:/var/lib/mysql/data
networks:
- overlay
deploy:
mode: replicated
replicas: 2
endpoint_mode: dnsrr
volumes:
db-data:
driver: local
driver_opts:
o: bind
type: none
device: /home/ubuntu/db-data/
VOLUMES FOR SERVICES, SWARMS, AND STACK FILES
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!