Mean Stack Application Deployment Using Docker Failed

The mean stack application loaded successfully but the datas not inserted successfully in mongodb.

The Dockerfile is as follows:-

  • docker-compose fails to resolve service hostname
  • SQL Server on Linux > Bulk Import error
  • Docker - what does `docker run --restart always` actually do?
  • Docker user Permission denied on accessing folder in container
  • Docker commands fails (in Windows)
  • Can't install pip packages inside a docker container with Ubuntu
  •         # Tells the Docker which base image to start.
            FROM node
    
            # Adds files from the host file system into the Docker container.  
            ADD . /app
    
            # Sets the current working directory for subsequent instructions
            WORKDIR /app
    
            COPY package.json /app
            RUN npm install
            RUN npm install -g bower
            RUN bower install --allow-root
            RUN npm install -g nodemon
    
            #expose a port to allow external access
            EXPOSE 3000
    
           # Start mean application
           CMD ["nodemon", "app.js"]
    

    The Dockerfile for mongo-seed :-

             FROM mongo:3.2
    
             COPY data.json /app/data.json
    
             CMD mongoimport --host mongodb --db items --collection items --type json --file /app/data.json --jsonArray
    

    The Docker file for mongo:-

             FROM mongo:3.2
    

    The docker-compose.yml file:-

                   version: '2'
                        services:
                              web:
                                   build: .
                                   volumes:
                                          - ./:/app
                                   ports:
                                          - "3000:3000"
                                   links:
                                          - mongo
                              mongo:
                                   image:
                                          mongo
                                   ports:
                                         - "27017:27017"
                                   volumes_from:
                                             - mongodata
                                   mongodata:
                                            build:
                                                  mongo-seed/.
                                            volumes:
                                                     - /data/db
    

    This is the error generated while running docker-compose:-

         Starting meanproductdemofinalvolume_mongodata_1
         Starting meanproductdemofinalvolume_mongo_1
         Starting meanproductdemofinalvolume_web_1
         Attaching to meanproductdemofinalvolume_mongodata_1, meanproductdemofinalvolume_mongo_1, meanproductdemofinalvolume_web_1
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=03796e33fa94
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten] db version v3.2.10
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1t  3 May 2016
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten] allocator: tcmalloc
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten] modules: none
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten] build environment:
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten]     distmod: debian81
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten]     distarch: x86_64
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten]     target_arch: x86_64
         mongo_1      | 2016-11-25T05:19:28.985+0000 I CONTROL  [initandlisten] options: {}
         mongo_1      | 2016-11-25T05:19:29.005+0000 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
         mongo_1      | 2016-11-25T05:19:29.006+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=2G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
         mongo_1      | 2016-11-25T05:19:30.495+0000 I CONTROL  [initandlisten] 
         mongo_1      | 2016-11-25T05:19:30.495+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
         mongo_1      | 2016-11-25T05:19:30.495+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
         mongo_1      | 2016-11-25T05:19:30.495+0000 I CONTROL  [initandlisten] 
        mongo_1      | 2016-11-25T05:19:30.495+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
        mongo_1      | 2016-11-25T05:19:30.495+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
        mongo_1      | 2016-11-25T05:19:30.495+0000 I CONTROL  [initandlisten] 
        mongo_1      | 2016-11-25T05:19:30.497+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
        mongo_1      | 2016-11-25T05:19:30.497+0000 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
        mongo_1      | 2016-11-25T05:19:30.498+0000 I NETWORK  [initandlisten] waiting for connections on port 27017
        web_1        | [nodemon] 1.11.0
        web_1        | [nodemon] to restart at any time, enter `rs`
        web_1        | [nodemon] watching: *.*
        web_1        | [nodemon] starting `node app.js`
        mongodata_1  | 2016-11-25T05:19:30.965+0000 [........................] items.items  0B/1.16KB (0.0%)
        web_1        | Express server listening on port : 3000
        mongo_1      | 2016-11-25T05:19:31.288+0000 I NETWORK  [initandlisten] connection accepted from 172.20.0.4:45957 #1 (1 connection now open)
        mongo_1      | 2016-11-25T05:19:31.293+0000 I NETWORK  [initandlisten] connection accepted from 172.20.0.4:45958 #2 (2 connections now open)
        mongo_1      | 2016-11-25T05:19:31.294+0000 I NETWORK  [initandlisten] connection accepted from 172.20.0.4:45959 #3 (3 connections now open)
        mongo_1      | 2016-11-25T05:19:31.296+0000 I NETWORK  [initandlisten] connection accepted from 172.20.0.4:45960 #4 (4 connections now open)
        mongo_1      | 2016-11-25T05:19:31.299+0000 I NETWORK  [initandlisten] connection accepted from 172.20.0.4:45961 #5 (5 connections now open)
        mongodata_1  | 2016-11-25T05:19:31.754+0000 [........................] items.items  0B/1.16KB (0.0%)
        mongodata_1  | 2016-11-25T05:19:31.754+0000 Failed: error connecting to db server: no reachable servers
        mongodata_1  | 2016-11-25T05:19:31.754+0000 imported 0 documents
        meanproductdemofinalvolume_mongodata_1 exited with code 1
    

  • How to publish a port different from the default one?
  • Ansible docker_container command failing with no output
  • Install shipyard on existing docker swarm
  • graphql and serverless offline running in docker
  • How can i create a superuser for elasticsearch from docker-compose
  • Dockerfile - how to run script?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.