Docker – How to run docker container with bash shell


It works with ubuntu image

wolf@linux:~$ docker run -it ubuntu /bin/bash

However, when I try it with different image such as vulnerables/web-dvwa, it doesn't work anymore

wolf@linux:~$ docker run -it vulnerables/web-dvwa /bin/bash
[+] Starting mysql...
[ ok ] Starting MariaDB database server: mysqld.
[+] Starting apache
[....] Starting Apache httpd web server: apache2AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message
. ok 
==> /var/log/apache2/access.log <==

==> /var/log/apache2/error.log <==
[Sat Apr 03 11:54:24.321232 2021] [mpm_prefork:notice] [pid 307] AH00163: Apache/2.4.25 (Debian) configured -- resuming normal operations
[Sat Apr 03 11:54:24.321280 2021] [core:notice] [pid 307] AH00094: Command line: '/usr/sbin/apache2'

==> /var/log/apache2/other_vhosts_access.log <==


There is no bash shell in this container

wolf@linux:~$ docker ps
CONTAINER ID   IMAGE                  COMMAND                CREATED          STATUS          PORTS     NAMES
820d3a292b2c   vulnerables/web-dvwa   "/ /bin/bash"   11 seconds ago   Up 11 seconds   80/tcp    upbeat_visvesvaraya

Best Answer

You can attach to the container with:

 docker exec -ti 820d3a292b2c bash


 docker exec -ti upbeat_visvesvaraya bash