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
If you add -e "PORT=3001" and so on to the second command, does that work? And you might want to specify a --name js3001 as well, or you won't be able to restart crashed containers easily.
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.
Thanks. Will test that tomorrow.
Hi @battletux,
thanks for sharing. It's working now. Don't know what the problem was two days ago as I was using the same commands.
This thread has been automatically locked because it has not had recent activity after it was closed. :lock: Please open a new issue for regressions or related bugs.
Most helpful comment
I too ran a CTF, last week in fact. For the setup I made a script that ran the needed number of instances:
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:
I just assigned each team/individual a specific port to use. Running _docker ps_ shows that 8 separate containers are now running:
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.