How to use docker to run sqli-labs(a web applicati

2019-08-23 15:24发布

问题:

I try to use Docker to run sqli-labs, I use the command:

docker pull acgpiano/sqli-labs

to pull the images, and after I use the command:

docker run -dt --name sqli -p 80:80 --rm acgpiano/sqli-labs

I visit the http://localhost, but my browser shows me 404.. here is the screenshot:

enter image description here

enter image description here

Why I can not get the right page?

回答1:

Because the page is not accessible on your machines localhost but on your containers localhost.

You can access it if you go to localhost inside your container or on your machines IP.

EDIT:

How to access localhost inside the container:

# I ran the same commands as you
docker pull acgpiano/sqli-labs
docker run -dt --name sqli -p 80:80 --rm acgpiano/sqli-labs
# First get the container id with 
docker ps -a
# I got this output:
# CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS                          NAMES
# d91384617370        acgpiano/sqli-labs   "/run.sh"           3 minutes ago       Up 3 minutes        0.0.0.0:80->80/tcp, 3306/tcp   sqli

# Then execute bash command as root for this container id
docker exec -it -u root d91384617370 bash

# Inside the container update apt-get and get curl (or wget)
apt-get update -y
apt-get install curl -y

# Go to localhost - the page will be printed in your terminal
curl localhost

How to access it in windows 10 (tested with Docker version 18.03.1-ce, build 9ee9f40), I'm using powershell and docker for windows

docker pull acgpiano/sqli-labs
docker run -dt --name sqli -p 80:80 --rm acgpiano/sqli-labs

# In powershell get the hostname - copy it to your browser - http://your_hostname or just your_hostname
hostname
# Or run ipconfig to find your IP - copy it to your browser http://your_ip or your_ip
ipconfig | findstr [0-9].\. 

I would also recommend this example from the docs, great way to get started.



标签: docker