question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker issue - How to spin up several docker containers?

See original GitHub issue

Hi all,

first of all great project and appreciate all the effort and hard work to build the Juice Shop.

I want to use the Juice Shop for an internal CTF and I already got the Juice-Shop running with CTFd. I only have now one problem: How can I easily spin up several docker instances of Juice Shop that all point to a different port, e.g. 3001, 3002 and 3003. So every attendee has it’s own Juice Shop?

If I execute the following command it’s pointing to the same container, just a different port

docker run -d -p 3001:3000 -e "NODE_ENV=ctf" -e "CTF_KEY=XXX" bkimminich/juice-shop

When doing this, I cannot connect to port 3001

docker run -d -p 3001:3001 -e "NODE_ENV=ctf" -e "CTF_KEY=XXX" bkimminich/juice-shop

I was already going through the docker docs but somehow couldn’t find an answer for this.

Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
battletuxcommented, Sep 24, 2017

I too ran a CTF, last week in fact. For the setup I made a script that ran the needed number of instances:

#!/bin/bash

docker run -d -p 3000:3000 -e "NODE_ENV=ctf" bkimminich/juice-shop
docker run -d -p 3001:3000 -e "NODE_ENV=ctf" bkimminich/juice-shop
docker run -d -p 3002:3000 -e "NODE_ENV=ctf" bkimminich/juice-shop
docker run -d -p 3003:3000 -e "NODE_ENV=ctf" bkimminich/juice-shop
docker run -d -p 3004:3000 -e "NODE_ENV=ctf" bkimminich/juice-shop
docker run -d -p 3005:3000 -e "NODE_ENV=ctf" bkimminich/juice-shop
docker run -d -p 3006:3000 -e "NODE_ENV=ctf" bkimminich/juice-shop
docker run -d -p 3007:3000 -e "NODE_ENV=ctf" bkimminich/juice-shop

When executed the script spins up 8 separate containers with ports 3000 to 3007 exposed and mapped back to port 3000 on their respective containers:

» ./jshop.sh
2de220b6b0430e6a592bc1a435d7981af71b280e33a32716a5b815fcbaa5a420
97ad864d44975d76fb6cc7b31b19e10eb27f14f34cba553b01dead0bcec63a57
f48dd5d0cba3014ed7286a80b23bd00656d7edfc7fb47142bc75ccae1ebe7355
eb728dd808bc387549680e978a2435120b5ff4b16748c060623bf84a00c55258
dccf20363987504024e6d467595f017c86196581dad775313cc356df60745f6e
ad6789b42e0a30442dc62c2c3111af785f243938d5f1ad4b1602ee80c7116466
36e08029760882054a679f99572bc903b9a0ff719bcff55c764f3285da85561c
95c377284318f86867cbcd00e72e955cfd07e5a926f2a31c3b5d130f7a62705a

~

I just assigned each team/individual a specific port to use. Running docker ps shows that 8 separate containers are now running:

» docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                    NAMES
95c377284318        bkimminich/juice-shop   "npm start"              47 seconds ago      Up 45 seconds       0.0.0.0:3007->3000/tcp   boring_goodall
36e080297608        bkimminich/juice-shop   "npm start"              48 seconds ago      Up 46 seconds       0.0.0.0:3006->3000/tcp   relaxed_wescoff
ad6789b42e0a        bkimminich/juice-shop   "npm start"              49 seconds ago      Up 47 seconds       0.0.0.0:3005->3000/tcp   determined_yalow
dccf20363987        bkimminich/juice-shop   "npm start"              49 seconds ago      Up 48 seconds       0.0.0.0:3004->3000/tcp   romantic_bhaskara
eb728dd808bc        bkimminich/juice-shop   "npm start"              50 seconds ago      Up 48 seconds       0.0.0.0:3003->3000/tcp   competent_raman
f48dd5d0cba3        bkimminich/juice-shop   "npm start"              51 seconds ago      Up 49 seconds       0.0.0.0:3002->3000/tcp   modest_varahamihira
97ad864d4497        bkimminich/juice-shop   "npm start"              51 seconds ago      Up 49 seconds       0.0.0.0:3001->3000/tcp   elated_ritchie
2de220b6b043        bkimminich/juice-shop   "npm start"              52 seconds ago      Up 50 seconds       0.0.0.0:3000->3000/tcp   angry_snyder
00afd0111e90        ctfd_ctfd               "/opt/CTFd/docker-..."   11 days ago         Up 3 days           0.0.0.0:9999->8000/tcp   ctfd_ctfd_1

~

Hope this helps. If you wish to make sure that the CTFd flags are different make sure that you add the same CTF_KEY command to each line and then run juice-shop-ctf and import that into CTFd so that all the flags are synced and working.

This all ran on a Mac book with no issues. Docker had 8gb of ram and 4 cpu threads which was a little overkill in hind sight.

Going forwards I’m looking into being able to spin up this on a number of raspberry pi’s for use as an easily mobile ctf. I just need to figure out the whole docker swarm thing and to have different instances instead of just a single load balanced one.

0reactions
lock[bot]commented, Nov 4, 2019

This thread has been automatically locked because it has not had recent activity after it was closed. 🔒 Please open a new issue for regressions or related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spinning up and Managing Multi-container apps using Docker ...
The first step to spin up multiple containers with docker-compose is to install docker depending on the operating system you are working on....
Read more >
Multi container apps - Docker Documentation
Start a new container using the nicolaka/netshoot image. Make sure to connect it to the same network. $ docker run -it --network todo-app...
Read more >
How to spin up several docker containers? · Issue #386 - GitHub
I only have now one problem: How can I easily spin up several docker instances of Juice Shop that all point to a...
Read more >
How to spin up multiple Docker containers with one command
First either create the images you will run or create the dockerfiles to build on the fly or have a image in mind...
Read more >
How to Use Docker Compose to Run Multiple Instances of a ...
Having a fast and easy way to spin up a system configuration with multiple instances of a service saves a lot of time...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found