2

Upon going inside the container, For some reason it reads the code from this location, I don't know how and from where is the code being loaded here: /home/mean

But the needed ( real code ) contents are being uploaded here:
/opt/ltg/

Here's my docker-compose file contents, I think the issue is with the VOLUMES parameter.

When i try to go inside the container, and look for the html views, turns out it is linked with another folder that i used before.

I'm using https://github.com/meanjs/mean meanjs to build my project so I'm using their docker files, so their way of using the docker.

version: '2'
services:
  web:
    restart: always
    build: .
    container_name: ltg
    ports:
     - "3000:3000"
     - "5858:5858"
     - "8080:8080"
     - "35729:35729"
    environment:
     - NODE_ENV=development
     - DB_1_PORT_27017_TCP_ADDR=db
    depends_on:
     - db
    volumes_from:
     - web-data
  web-data:
    build: .
    entrypoint: /bin/true
    volumes:
     - ./:/opt/ltg
     - /opt/ltg/node_modules
     - /opt/ltg/public
     - /opt/ltg/uploads
  db:
    image: mongo:3.2
    restart: always
    ports:
     - "27017:27017"
    volumes_from:
      - db-data
  db-data:
    image: mongo:3.2
    volumes:
      - /data/db
      - /var/lib/mongodb
      - /var/log/mongodb
    entrypoint: /bin/true

Dockerfile. ( I think the issue is here ) but even when i change the /home/mean to /opt/ltg it doesn't seem to work.

 FROM node:0.12

# Install gem sass for  grunt-contrib-sass
RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get install -y ruby
RUN gem install sass

WORKDIR /opt/ltg

# Install Mean.JS Prerequisites
RUN npm install -g grunt-cli
RUN npm install -g bower

# Install Mean.JS packages
ADD package.json /opt/ltg/package.json
RUN npm install

# Manually trigger bower. Why doesnt this work via npm install?
ADD .bowerrc /opt/ltg/.bowerrc
ADD bower.json /opt/ltg/bower.json
RUN bower install --config.interactive=false --allow-root

# Make everything available for start
ADD . /opt/ltg

# Set development environment as default
ENV NODE_ENV development

# Port 3000 for server
# Port 35729 for livereload
EXPOSE 3000 35729
CMD ["grunt"]

When i go inside the docker machine I can see that it does have the code inside but I dont know why is it picking it from another place.

inside docker container

Docker inspect

± docker inspect e8a6e44e7a78
[
    {
        "Id": "e8a6e44e7a78825d5d4ebd9e165d24151e391e66478a5214f0ecd7badcf71d51",
        "Created": "2016-11-11T21:51:59.315251772Z",
        "Path": "grunt",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 6521,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2016-11-11T21:52:00.23437815Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:8b93f26cc274bf69cd9e2c24161ef8b1a09acc958fb94027838897b0bf860d4e",
        "ResolvConfPath": "/var/lib/docker/containers/e8a6e44e7a78825d5d4ebd9e165d24151e391e66478a5214f0ecd7badcf71d51/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/e8a6e44e7a78825d5d4ebd9e165d24151e391e66478a5214f0ecd7badcf71d51/hostname",
        "HostsPath": "/var/lib/docker/containers/e8a6e44e7a78825d5d4ebd9e165d24151e391e66478a5214f0ecd7badcf71d51/hosts",
        "LogPath": "/var/lib/docker/containers/e8a6e44e7a78825d5d4ebd9e165d24151e391e66478a5214f0ecd7badcf71d51/e8a6e44e7a78825d5d4ebd9e165d24151e391e66478a5214f0ecd7badcf71d51-json.log",
        "Name": "/ltg",
        "RestartCount": 0,
        "Driver": "overlay2",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "ltg_default",
            "PortBindings": {
                "3000/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "3000"
                    }
                ],
                "35729/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "35729"
                    }
                ],
                "5858/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "5858"
                    }
                ],
                "8080/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8080"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "always",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": -1,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0
        },
        "GraphDriver": {
            "Name": "overlay2",
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/aedc2da47ce0785a68ea3786cf35eded82b6e5eb57e7083353d2c68ebfa1d15e-init/diff:/var/lib/docker/overlay2/ba7c11c0aac2c7c97c6f0d2876ed600b3724c0cabaa40d58f579db4573b4e8ed/diff:/var/lib/docker/overlay2/807a7a90f77a22724db8e54a57ad91b1ef1f2b06e88ad42524042f46c9da39d7/diff:/var/lib/docker/overlay2/14cbc06a270e4fddd6287d8f90cb2e885b1387be4dc0b79678f866b59e12063c/diff:/var/lib/docker/overlay2/369cc5f5a0ba13fe12e2d42d35f78f1bfcfdd80c0a0d64f0a22e9a6a036149aa/diff:/var/lib/docker/overlay2/854bf8973559090707e5d89c820ae70539392f9970b1646fb8178ff401ae3c5b/diff:/var/lib/docker/overlay2/d6db404071f5f6741dc2555bb87142f0fbfb511a7c70f03085ddcae108bbf5ae/diff:/var/lib/docker/overlay2/869b67fd3eb7e0f4856433eddd0dd1604170bf8d70c97070a4c1866c46a82024/diff:/var/lib/docker/overlay2/2fa6daceeb2d0b83fcb08a8b46d8894f182c8e2bb206e87d5af0e7fc73452c29/diff:/var/lib/docker/overlay2/b61d40c66620b7088c0ba4d37e776eef9a40ece901cf2e1ead26c8cbde3ebfe5/diff:/var/lib/docker/overlay2/c2470f33522483b8c7f2651e24ebee088f27fcdac2b8b93e9183e5d022ebc883/diff:/var/lib/docker/overlay2/a48f7cee20a989218f7eb20a8d6bc0b31a3c3e4e968a0a5271a13297a2b37b89/diff:/var/lib/docker/overlay2/e69b54cfe8a5a5c5cacf5e77603bd6e24695dba569c6bf5b0c9788f4b008c22c/diff:/var/lib/docker/overlay2/2dd3ff884efc421fed1e548a4b0c6c633dd59b62c077811718ed5b7bf0fde7fd/diff:/var/lib/docker/overlay2/b5c1cc249ce2798dbfff752cd2f4878bc7777951cd11013ceecb44d0eb933aff/diff:/var/lib/docker/overlay2/e9006ecc5d8f18345f402c96e9149b2b0dd6689d1d476b896049237ea41de404/diff:/var/lib/docker/overlay2/2debe0ee8462910da0e18bbd9ac6c1c902b157f7b15b23f866add9163d008aa3/diff:/var/lib/docker/overlay2/d0bc087a8ea87721eb7feb31dd7999e6e9755e991b88f4e728fc93669ee8590e/diff:/var/lib/docker/overlay2/76deca402cfba36204612590cb0de02a5ff8fab6d6053263af0a81e6da79fb78/diff:/var/lib/docker/overlay2/737638f3bceb8c85288c3477da936e3b523dbabd787e72989e639df24195329b/diff",
                "MergedDir": "/var/lib/docker/overlay2/aedc2da47ce0785a68ea3786cf35eded82b6e5eb57e7083353d2c68ebfa1d15e/merged",
                "UpperDir": "/var/lib/docker/overlay2/aedc2da47ce0785a68ea3786cf35eded82b6e5eb57e7083353d2c68ebfa1d15e/diff",
                "WorkDir": "/var/lib/docker/overlay2/aedc2da47ce0785a68ea3786cf35eded82b6e5eb57e7083353d2c68ebfa1d15e/work"
            }
        },
        "Mounts": [],
        "Config": {
            "Hostname": "e8a6e44e7a78",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "3000/tcp": {},
                "35729/tcp": {},
                "5858/tcp": {},
                "8080/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "NODE_ENV=development",
                "DB_1_PORT_27017_TCP_ADDR=db",
                "no_proxy=*.local, 169.254/16",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NODE_VERSION=0.12.17"
            ],
            "Cmd": [
                "grunt"
            ],
            "Image": "ltg_web",
            "Volumes": null,
            "WorkingDir": "/home/mean",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "7a3cb3d6a460fc5a975aafe44279ec835e5bb92141ae537ac0fd044c94243abe",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "ltg",
                "com.docker.compose.service": "web",
                "com.docker.compose.version": "1.9.0-rc2"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "a1b78ae1a7e589977a6f23e1fe1274bb494324b7ce7b9f99d16bb7e78678f721",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "3000/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "3000"
                    }
                ],
                "35729/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "35729"
                    }
                ],
                "5858/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "5858"
                    }
                ],
                "8080/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8080"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/a1b78ae1a7e5",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "ltg_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "web",
                        "e8a6e44e7a78"
                    ],
                    "NetworkID": "cdde7613dceaf26fac855d124172f3b0606ab685585a69974e87c4f4ed4fed6c",
                    "EndpointID": "b4618fb75407538391035f610281374407c9b9a513028ccf981a390d689dbe93",
                    "Gateway": "172.19.0.1",
                    "IPAddress": "172.19.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:13:00:03"
                }
            }
        }
    }
]

I dont undersatnd from where is this /home/mean coming inside the variable

    "WorkingDir": "/home/mean",
JP.
  • 1,035
  • 2
  • 17
  • 39
  • Why are you using host based volumes with a data container (obsolete pattern) to map volumes from the host into web-data and then into web? This is unnecessary complexity. – BMitch Nov 11 '16 at 02:45
  • What do you mean ? I didn't get – JP. Nov 11 '16 at 02:46
  • You took a data container from upstream (likely to support legacy users on very old versions of docker) and modified the volumes to mount directories from the host. There's no need for the data container at that point, just mount your volumes directly in the web container and completely delete the web-data container. – BMitch Nov 11 '16 at 02:49
  • @BMitch I think you're thinking in right direction. How do i do this "just mount your volumes directly in the web container and completely delete the web-data container. " – JP. Nov 11 '16 at 04:26

1 Answers1

0

I think we need a little more information to properly answer the question. So I will assume some things.

  1. The opt/ltg directory points to the directory where your docker-compose.yml is located, not the directory where you run docker-compose. Usually is the same directory. Try to make a modification I your docker-compose.yml like add a comment. Go to the container with docker exec and check the content of your docker-compose.yml, the added comment should be there.

  2. I assume that your html files go to /opt/ltg/public as you declared it as a volume also. Docker will create another directory in your host for this different from your current directory. Use a docker inspect to see where are they. If you run a docker-compose down -v you should get rid of those files.

  3. Don't overlap volumes unless you really need to. I recommend use this docker-compose.yml instead:

docker-compose.yml

version: '2'
services:
  web:
    restart: always
    build: .
    container_name: ltg
    ports:
     - "3000:3000"
     - "5858:5858"
     - "8080:8080"
     - "35729:35729"
    environment:
     - NODE_ENV=development
     - DB_1_PORT_27017_TCP_ADDR=db
    depends_on:
     - db
    volumes_from:
     - web-data
  web-data:
    build: .
    entrypoint: /bin/true
    volumes:
     - ./:/opt/ltg
  db:
    image: mongo:3.2
    restart: always
    ports:
     - "27017:27017"
    volumes_from:
      - db-data
  db-data:
    image: mongo:3.2
    volumes:
      - /data/db
      - /var/lib/mongodb
      - /var/log/mongodb
    entrypoint: /bin/true

Regards

Carlos Rafael Ramirez
  • 5,984
  • 1
  • 29
  • 36
  • I'm using https://github.com/meanjs/mean meanjs to build my project so I'm using their docker files, so their way of using the docker. – JP. Nov 10 '16 at 14:44
  • In this page I can see you are issuing `$ docker-compose -f docker-compose-production.yml up -d` it is important you include this in the question. Read what I wrote in point 1. – Carlos Rafael Ramirez Nov 10 '16 at 15:04
  • where do you see the docker-compose -f docker-compose-production.yml I've done the diagnostics and i've updated the question. pls read on the top. – JP. Nov 11 '16 at 04:18