Swagger express gives error inside docker container

I have an app that uses the swagger-express-mw library and I start my app the following way:

SwaggerExpress.create({ appRoot: __dirname }, (err, swaggerExpress) => {  
// initialize application, connect to db etc...

Everything works fine on my local OSX machine. But when I use boot2docker to build an image from my app and run it, I get the following error:

  • chef-server stuck ruby_block[supervise_rabbitmq_sleep] action run on Docker container
  • Tips on getting docker to work without having to run `sudo docker -d` on Ubuntu 15.04
  • Reducing the shipping time in continuous delivery, especially in hotfix
  • How to verify my docker-compose.yml?
  • What causes flume with GCS sink to throw a OutOfMemoryException
  • Restart a process inside a Docker container whenever the config file changes
  • /usr/src/app/node_modules/swagger-node-runner/index.js:154
    config.swagger = _.defaults(readEnvConfig(),
    TypeError: Cannot assign to read only property 'swagger' of [object Object]

    My dockerfile looks like this (nothing special):

    FROM node:latest
    RUN mkdir -p /usr/src/app
    WORKDIR /usr/src/app
    COPY package.json /usr/src/app/
    RUN npm set progress=false
    RUN npm install
    COPY . /usr/src/app
    EXPOSE 5000
    CMD ["npm", "run", "dev"]

    Has anyone else encountered similar situations where the local environment worked but the app threw an error inside the docker container?


  • Couldn't resolve host within docker container and java process
  • Docker volumes doesn't exist for data container in 1.9.1
  • docker-swarm and docker-compose how to dynamically add nodes and have them resolvable by the services
  • What is the name of the Docker daemon?
  • really long environment variable in Dockerfile
  • How to use `docker-machine create` so that the docker engine listens on a custom port?
  • One Solution collect form web for “Swagger express gives error inside docker container”

    Your issue doesn’t appear to be something wrong with your docker container or machine setup. The error is not a docker error, that is a JavaScript error.

    The docker container appears to be running your JavaScript module in Strict Mode, in which you cannot assign to read-only object properties (https://msdn.microsoft.com/library/br230269%28v=vs.94%29.aspx). On your OSX host, from the limited information we have, it looks like it is not running in strict mode.

    There are several ways to specify the “strictness” of your scripts. I’ve seen that you can start Node.js with a flag --use_strict, but I’m not sure how dependable that is. It could be that NPM installed a different version of your dependent modules, and in the different version they specify different rules for strict mode. There are several other ways to define the “strictness” of your function, module, or app as a whole.

    You can test for strict mode by using suggestions here: Is there any way to check if strict mode is enforced?.

    So, in summary: your issue is not inheritantly a docker issue, but it is an issue with the fact that your javascript environments are running in different strict modes. How you fix that will depend on where strict is being defined.

    Hope that helps!

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.