MySQL telepítése Docker konténerben – lépésről lépésre!

MySQL telepítése Docker konténerben – lépésről lépésre!

Ápr 02, 2019 ubuntu code snippets docker knowledge base

Docker telepítése és MySQL konténer futtatása

Ha Docker-t akarsz telepíteni Ubuntu-ra, nézd meg ezt a részletes cikket:
Így telepítsd a Docker-t Ubuntu-ra.

Indítsunk egy MySQL konténert háttérben, root jelszó: test.

docker run --rm -it -e MYSQL_ROOT_PASSWORD=test -d mysql
  • -d: háttérben fut, kiírja a konténer ID-t
  • --rm: kilépéskor törlődik a konténer

Futó konténerek listája

docker ps
CONTAINER ID      IMAGE    COMMAND                  CREATED        STATUS     PORTS                   NAMES
8ee2e6c8174d      mysql    "docker-entrypoint.s…"   9 mp ezelőtt  Up 7 mp    3306/tcp, 33060/tcp     condescending_snyder

MySQL shell a konténerben

docker exec -it 8ee2e6c8174d mysql -u root -ptest
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.15 MySQL Community Server - GPL

mysql>

Konténer részletes infói

Hálózati beállítások, kötetek és egyebek megtekintése.

docker inspect 8ee2e6c8174d
[
    {
        "Id": "8ee2e6c8174d4138026f1d54addf9aadc7fbe22727c7f1fb9ca996ce5f7601b2",
        "Created": "2019-03-28T20:53:46.84185469Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "mysqld"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
        ...
        "Networks": {
            "bridge": {
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.2",
                "IPPrefixLen": 16,
                "MacAddress": "02:42:ac:11:00:02"
            }
        }
    }
]

Csatlakozás IP-címmel a MySQL-hez

mysql -u root -ptest -h 172.17.0.2

Minden konténer (futók + leálltak)

docker ps -a
CONTAINER ID     IMAGE     COMMAND                  CREATED       STATUS                    PORTS                  NAMES
8ee2e6c8174d     mysql     "docker-entrypoint.s…"   2 perc ezelőtt  Up 2 perc               3306/tcp, 33060/tcp   condescending_snyder
913f33f5a848     mysql     "docker-entrypoint.s…"   12 perc ezelőtt Exited (0) 11 perc ezelőtt              jovial_dubinsky
b36cf8b3b664     mysql     "docker-entrypoint.s…"   22 perc ezelőtt Exited (1) 22 perc ezelőtt              cocky_mcnulty

Minden elérhető image

docker images
REPOSITORY  TAG     IMAGE ID      CREATED     SIZE
mysql       latest  7bb2586065cd  45 órája    477MB

Read in other languages:

EN ES SV RO DE FR NL PL EL BG RU CS PT NB FI IT DA ZH-HANS UZ TR