LoginSignup
0
0

Docker Tutorial #3 Docker run Nginx, Httpd, Mysql and Ubuntu (2023)

Posted at

image.png

Target commands

docker run mysql
docker run nginx
docker run httpd
docker run ubuntu

Mysql

image.png

terminal
    docker run -d --name db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pw mysql

Httpd

image.png

terminal
    docker run -d --name webserver -p 8080:80 httpd

Nginx

image.png

terminal
    docker run -d --name nginx -p 80:80 nginx

Ubuntu

image.png

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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0