Exposing a port other than 3000 with Express and Docker

Viewed 4253

I'm using Docker to run an Express app and everything is fine if I run it on port 3000. The Dockerfile I'm using for that is

FROM node:boron

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

EXPOSE 3000
CMD ["npm", "start" ]

I now wanted to run it on port 3500. I adjusted the Dockerfile to

FROM node:boron

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

EXPOSE 3500
CMD ["PORT=3500", "npm", "start" ]

and the docker run command to

docker run -p 3500:3500 me/myapp

It throws the following error

container_linux.go:262: starting container process caused "exec: \"PORT=3500\": executable file not found in $PATH"

I'm sure this is something basic but I'm new to this and couldn't find the solution by googling it. A pointer in the right direction would be very much appreciated.

1 Answers
Related