Target commands
docker run mysql
docker run nginx
docker run httpd
docker run ubuntu
Mysql
terminal
docker run -d --name db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pw mysql
Httpd
terminal
docker run -d --name webserver -p 8080:80 httpd
Nginx
terminal
docker run -d --name nginx -p 80:80 nginx
Ubuntu
terminal
docker run -d -it --name ubuntu ubuntu
Docker stats
The docker stats command returns a live data stream for running containers.
terminal
docker stats
Getting a shell inside Containers
The docker exec command runs a new command in a running container.
terminal
docker exec -it db bash
bash-4.4#
mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.33 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
bash-4.4#
bash-4.4# exit
exit