16
version: "3"
services:
   mongo:
      image: mongo
      working_dir: /c/data/
      ports:
       - 27017:27017
      deploy:
        replicas: 1
      volumes:
        - /c/data/:/data/db

I am tried that above stack file and I'm receiving exit code 14 error please give me the solution about the error,

Mihai
  • 9,526
  • 2
  • 18
  • 40
yasar khan
  • 171
  • 1
  • 1
  • 4
  • `working_dir` refers to a directory inside the container, not on the host. you need to make sure `/c/data/` can be created on the node where the container runs (it is quite a weird path...). It is generally better to avoid using host volumes when working with stacks. – Mihai Sep 22 '20 at 07:18

6 Answers6

11

Delete everything from /c/data/, in case there are some data from older version of Mongo

  • Yes, it is work but do I have to delete it every time? If I delete everything from `/c/data/` then it's work so I start the db and the files are recreated. When I restart the db I get exit code 14 error. – capo11 Dec 09 '20 at 09:53
  • I guess so.. only in case of upgrade/downgrade's.. I didn't found any workarounds at the moment – Ivan Nedelcev Dec 10 '20 at 10:21
  • 1
    This worked for me, along with using the `-d` flag. – Austin Brown Jan 21 '21 at 16:28
  • 4
    If I was ok with deleting data, then why would I make shared volume? – Dims Jan 26 '21 at 11:47
9

In your terminal:

docker system prune

Works for me. Kew Approves =)

*Please, be careful! it clears everything!!

Airton
  • 91
  • 1
  • 4
2

It depends how you get up the service, for example use:

docker-compose up -d (on Windows)

instead of docker-compose up. In this way you have the control on terminal to call docker-compose down and the MongoDB process can terminate correctly.

capo11
  • 790
  • 3
  • 11
  • 32
1

On a Mac, you might be able to resolve the issue by deleting the /Users/{your account}/data folder.

You should be able to find the folder by going to Finder -> Go -> Go to Folder -> And search ~/Users/.

Other solutions that I tried before this that didn't work:

  • stopping and removing all mongo containers
  • removing all mongo images
  • Clean / Purge data from Docker Desktop
  • uninstall and reinstall Docker
Brian Li
  • 2,260
  • 1
  • 15
  • 18
1

For me what helped is deleting the mounted host directory, deleting the volume with docker volume rm {CONTAINER NAME\ID}. Make sure to write the volume in compose right, for example:

  ...

  database:
    container_name: database
    image: mongo
    ports:
      - '27017:27017'
    volumes:
      - db:/data/db  
  ...  
  volumes: 
    db:  

BenLa
  • 27
  • 1
  • 6
0
  1. Install WSL2 ( It requires recent windows update)
  2. Docker -> Settings -> Enable-> Use WSL 2 based engine
Muthukumar R
  • 141
  • 1
  • 7
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30487406) –  Dec 03 '21 at 01:30