Skip to content

Instantly share code, notes, and snippets.

@tarnacious
Last active August 18, 2021 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarnacious/40dd3070d5819817cbf63490002c5fd1 to your computer and use it in GitHub Desktop.
Save tarnacious/40dd3070d5819817cbf63490002c5fd1 to your computer and use it in GitHub Desktop.
run a bunch of express js hello world programs in docker containers
bash run.sh
FROM node:latest
WORKDIR /app
COPY . .
RUN yarn
CMD ["node", "index.js"]
const express = require('express')
const app = express()
const port = process.env.PORT
app.get('/', (req, res) => {
res.send(`Hello World from port ${port}!`)
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
{
"name": "express",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"express": "^4.17.1"
}
}
#!/usr/bin/env bash
docker build -t helloworld .
for i in {3000..3200}; do
docker run -d --env PORT=$i -p $i:$i helloworld;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment