Docker Community Forums

Share and learn in the Docker community.

Accessing directly a MySQL shell on Mac OX El-Captain


(Oscar) #1

Here https://hub.docker.com/_/mysql/ it shows how to directly access a MySQL shell:

$ docker run -it --link some-mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

I’m trying to figure out how this would look like in my case.

  1. docker pull tenzan/mysql:20151214

  2. Run mysql-cont container on the basis of downloaded tenzan/mysql:20151214:
    docker run --name mysql-cont -e MYSQL_ROOT_PASSWORD=root -d tenzan/mysql:20151214

  3. Here should I re-factor the very fist command to access directly a MySQL shell on top of mysql-cont ?

Thanks.


(Anoop) #2

Yes, but you could simplify it further if most of the options you’re using are the defaults. Please see below & let me know if it helps or you need more info:

root@ip-172-31-12-1:~# docker run --name mysql-cont -e MYSQL_ROOT_PASSWORD=root -d tenzan/mysql:20151214
Unable to find image 'tenzan/mysql:20151214' locally
20151214: Pulling from tenzan/mysql
756104f7750e: Pull complete
53fa043ba705: Pull complete
6035d8efd4a2: Pull complete
95868108c081: Pull complete
Digest: sha256:b733eb67e4c743a679afb6053104528176940b39b0956854fa7bde13a78ccad0
Status: Downloaded newer image for tenzan/mysql:20151214
81db2f8ddc4db31e2d5ecfa63cacb30bb4ebbaf44820863eccda1fdf00883817

root@ip-172-31-12-1:~# docker run -it --link sql:mysql-cont --rm mysql sh -c 'exec mysql -hsql -uroot -p'
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

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>

(Oscar) #3

Thanks.

But I got the following error when ran 2nd command:

$ docker run -it --link sql:mysql-cont --rm mysql sh -c 'exec mysql -hsql -uroot -p'
Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql

Digest: sha256:dde668fcea53f2ac511eda13a32c6ef32f34facbe8d4cd152dd30b27f138fc8b
Status: Downloaded newer image for mysql:latest
Error response from daemon: Could not get container for sql

Also I can understand why do I need to download mysql image as I already have mysql with my packed database in the tenzan/mysql:20151214 ?


(Anoop) #4

Oh yes, you can use the image you have already (tenzan/mysql), you do not need the official mysql image.

It would be like this:

docker run -it --link sql:mysql-cont --rm tenzan/mysql:20151214 sh -c 'exec mysql -hsql -uroot -p'

About your error, what happened when you ran the first command I posted above? Here it is again:

docker run --name mysql-cont -e MYSQL_ROOT_PASSWORD=root -d tenzan/mysql:20151214

If it still fails, can you please post the output of the commands:

docker ps -a
docker logs mysql-cont

(Oscar) #5

Thanks again.

So, to start from the beginning, I’ve removed all related containers (or images ?) and confirmed with docker images.

Outputs as follows:

$ docker run --name mysql-cont -e MYSQL_ROOT_PASSWORD=root -d tenzan/mysql:20151214
Unable to find image 'tenzan/mysql:20151214' locally
20151214: Pulling from tenzan/mysql

5971b6ce764f: Pull complete
647b436534ed: Pull complete
a62546ced626: Pull complete
ae83af27a2dd: Pull complete
4cb4f862d994: Pull complete
a7c37483ad01: Pull complete
6838bb2f0679: Pull complete
ca369de2f9aa: Pull complete
61e1545850dc: Pull complete
1dfcc2e5b6c2: Pull complete
8c1c3732f2da: Pull complete
f5f84dea6330: Pull complete
be8cee672400: Pull complete
b01706fbc5a4: Pull complete
756104f7750e: Pull complete
53fa043ba705: Pull complete
6035d8efd4a2: Pull complete
95868108c081: Pull complete
Digest: sha256:b733eb67e4c743a679afb6053104528176940b39b0956854fa7bde13a78ccad0
Status: Downloaded newer image for tenzan/mysql:20151214
Error response from daemon: Conflict. The name "mysql-cont" is already in use by container 83fa3c455dc2. You have to remove (or rename) that container to be able to reuse that name.

I’m not sure where mysql-cont was hiding :smile: but I’ve removed by docker rm mysql-cont

Then re-run the 1st command again

$ docker run --name mysql-cont -e MYSQL_ROOT_PASSWORD=root -d tenzan/mysql:20151214
5803f67285d81644cb65463d08029a733853f7bd5782565bea46924ea6646b1d

Confirmed the container is running:

$ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                           NAMES
5803f67285d8        tenzan/mysql:20151214   "/entrypoint.sh mysql"   22 seconds ago      Up 21 seconds       3306/tcp                        mysql-cont

Then ran 2nd command but got error:

$ docker run -it --link sql:mysql-cont --rm tenzan/mysql:20151214 sh -c 'exec mysql -hsql -uroot -p'
Error response from daemon: Could not get container for sql

And

$ docker ps -a
CONTAINER ID        IMAGE                   COMMAND                  CREATED              STATUS                     PORTS                           NAMES
5803f67285d8        tenzan/mysql:20151214   "/entrypoint.sh mysql"   About a minute ago   Up About a minute          3306/tcp                        mysql-cont
02814ec096ed        d792ce55daf3            "/bin/sh -c 'mkdir /d"   4 hours ago          Exited (1) 4 hours ago                                     focused_mietner
d8f81c1d292a        d792ce55daf3            "/bin/sh -c 'mkdir /d"   4 hours ago          Exited (1) 4 hours ago                                     lonely_shaw
903923b67a8a        nginx                   "nginx -g 'daemon off"   5 hours ago          Up 5 hours                 443/tcp, 0.0.0.0:8080->80/tcp   reverent_wing
c2e5d5cd08ad        nginx-cont              "nginx -g 'daemon off"   3 days ago           Exited (137) 5 hours ago   443/tcp, 0.0.0.0:8080->80/tcp   nginx-cont
8bda0a727f45        eece7cc921a6            "nginx -g 'daemon off"   3 days ago           Exited (1) 3 days ago                                      furious_kirch
58029c8452bd        6e3c467f6b46            "nginx -g 'daemon off"   3 days ago           Exited (1) 3 days ago                                      condescending_ritchie
1938ea37889c        7c509b1546ed            "nginx -g 'daemon off"   3 days ago           Exited (1) 3 days ago                                      nginx
e22d9e0290ce        b01706fbc5a4            "/bin/sh -c '/bin/bas"   3 days ago           Exited (1) 3 days ago                                      backstabbing_mcnulty
7a071b564f8b        b01706fbc5a4            "/entrypoint.sh /bin/"   3 days ago           Exited (130) 3 days ago                                    suspicious_wing
8b1c55add2cc        38852d95a766            "/bin/bash"              3 days ago           Exited (1) 3 days ago                                      elegant_hoover
7b95739a40d2        38852d95a766            "/bin/bash"              3 days ago           Exited (0) 3 days ago                                      lonely_mirzakhani
75bf6aa172c0        b01706fbc5a4            "/entrypoint.sh MYSQL"   4 days ago           Exited (127) 4 days ago                                    nostalgic_banach
2353ac01dd82        b01706fbc5a4            "/entrypoint.sh MYSQL"   4 days ago           Exited (127) 4 days ago                                    happy_panini

(Anoop) #6

It seems to run perfectly on my system. I copy pasted from your last post.

root@ip-172-31-12-1:~# docker run --name mysql-cont -e MYSQL_ROOT_PASSWORD=root -d tenzan/mysql:20151214
163c851735d0092cd0ebffeab61d983014b25fe53c0c9863b1bb9cedc8161b42
root@ip-172-31-12-1:~# docker run -it --link sql:mysql-cont --rm tenzan/mysql:20151214 sh -c 'exec mysql -hsql -uroot -p'
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

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>

OK, lets try a few more things. Please run these & send me the output if it still doesn’t work.

docker info
docker version
docker rm -f $(docker ps -qa)
docker rmi $(docker images -qa)
docker run --name mysql-cont -e MYSQL_ROOT_PASSWORD=root -d tenzan/mysql:20151214
docker inspect mysql-cont
docker run -it --link sql:mysql-cont --rm tenzan/mysql:20151214 sh -c 'exec mysql -hsql -uroot -p'

(Oscar) #7

I’m running these on Mac OS X El-Captain.

Something weird is happening with my computer. I’m still getting errors…

$ docker info
Containers: 14
Images: 24
Server Version: 1.9.1
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 52
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.13-boot2docker
Operating System: Boot2Docker 1.9.1 (TCL 6.4.1); master : cef800b - Fri Nov 20 19:33:59 UTC 2015
CPUs: 1
Total Memory: 1.956 GiB
Name: default
ID: YUQR:HKAA:XALI:ADFD:SEFP:Q33H:CQE7:HHTR:DUCW:SHCO:YDO3:LP7G
Debug mode (server): true
 File Descriptors: 31
 Goroutines: 109
 System Time: 2015-12-14T06:23:34.255814141Z
 EventsListeners: 1
 Init SHA1:
 Init Path: /usr/local/bin/docker
 Docker Root Dir: /mnt/sda1/var/lib/docker
Username: tenzan
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox

$ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

$ docker rm -f $(docker ps -qa)
5803f67285d8
02814ec096ed
d8f81c1d292a
903923b67a8a
c2e5d5cd08ad
8bda0a727f45
58029c8452bd
1938ea37889c
e22d9e0290ce
7a071b564f8b
8b1c55add2cc
7b95739a40d2
75bf6aa172c0
2353ac01dd82

$ docker rmi $(docker images -qa)
Untagged: tenzan/mysql:20151214
Deleted: 95868108c081ea916ac4f7120952b9db21e8b49f614e8831e5944a6b9369d957
Deleted: 6035d8efd4a20f1a3e512b5a9ea596fedf2687e22da5428826d466b78d217b64
Deleted: 53fa043ba705c4d79c1dbc11becef3bcb7a89d31823939fd31ce0548687cae0b
Deleted: 756104f7750e3a4e4ed44a6b874d0b76c98c6fad049cbca2482f1ab56e014b67
Deleted: b01706fbc5a46fa3520157d1bfa5d93dd930a68f07e910ce425d148e50c9df13
Deleted: be8cee67240081ad801b3daa2ad2157872fec586c4a0abee6ca5db24c7baf750
Deleted: f5f84dea633016d541209746014dbc0ffa80866fba8b452ced346ac7f9093988
Deleted: 8c1c3732f2da61301e5301ca85cafbe331785f1d36c640996eb38e3a672c7dbd
Deleted: 1dfcc2e5b6c27e8e722b62944b0c40bdb4777f39d4c7b096755d84e61ae9cde8
Deleted: 61e1545850dc27360adc23327690c52e577bbcaae9f98e93f86c9af73f83dcfd
Deleted: ca369de2f9aad2005f712b150267a08d28222e64fddee9cfae835d9a7dad0048
Deleted: 6838bb2f0679b0f8da0cc32f72216590ac1e5f927125784e49e573e32d9adc6a
Deleted: a7c37483ad019ad1d8e75985b0dcfe710a68631a04c25f1185d747eb4ddc9ac8
Deleted: 4cb4f862d99443a2d4b8debea2231eb45de443737df2ab5ff3cd52e6c96f7720
Deleted: ae83af27a2dda5a13b650ee3fdd316c5422db67185379db54215e5181d8b44ea
Deleted: a62546ced6266bc873e1b0f05f4438787e1758e2f3a1508849dda9e965c36ecb
Deleted: 647b436534ed69fc0966039d7abbc50514b9e1999e62c6c3c664971feab3b2a3
Deleted: 5971b6ce764fb36f7e4a2f23357f8fdc6953ef0ab9cc4cbc90050175f80255a5
Deleted: 23cb15b0fcece0623d706e9dbc3d9fce97937fb50ab3fbff8574206d258b6303
Deleted: 9ee13ca3b908aacceeb9eb6a3028d4566aa997ffc90915d55578a487f058e935
Error response from daemon: could not find image: no such id: 53fa043ba705
Error response from daemon: could not find image: no such id: 6035d8efd4a2
Error response from daemon: could not find image: no such id: 756104f7750e
Error response from daemon: conflict: unable to delete 89d5d8e8bafb (must be forced) - image is referenced in one or more repositories
Error response from daemon: conflict: unable to delete 89d5d8e8bafb (must be forced) - image is referenced in one or more repositories
Error response from daemon: conflict: unable to delete e24428725dd6 (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete 1796d1c62d0c (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete 0bf056161913 (cannot be forced) - image has dependent child images
Error response from daemon: could not find image: no such id: b01706fbc5a4
Error response from daemon: could not find image: no such id: be8cee672400
Error response from daemon: could not find image: no such id: f5f84dea6330
Error response from daemon: could not find image: no such id: 1dfcc2e5b6c2
Error response from daemon: could not find image: no such id: 8c1c3732f2da
Error response from daemon: could not find image: no such id: 61e1545850dc
Error response from daemon: could not find image: no such id: ca369de2f9aa
Error response from daemon: could not find image: no such id: 6838bb2f0679
Error response from daemon: could not find image: no such id: 4cb4f862d994
Error response from daemon: could not find image: no such id: a7c37483ad01
Error response from daemon: could not find image: no such id: ae83af27a2dd
Error response from daemon: could not find image: no such id: a62546ced626
Error response from daemon: could not find image: no such id: 647b436534ed
Error response from daemon: could not find image: no such id: 5971b6ce764f
Error response from daemon: could not find image: no such id: 23cb15b0fcec
Error response from daemon: could not find image: no such id: 9ee13ca3b908
Error: failed to remove images: [53fa043ba705 6035d8efd4a2 756104f7750e 89d5d8e8bafb 89d5d8e8bafb e24428725dd6 1796d1c62d0c 0bf056161913 b01706fbc5a4 be8cee672400 f5f84dea6330 1dfcc2e5b6c2 8c1c3732f2da 61e1545850dc ca369de2f9aa 6838bb2f0679 4cb4f862d994 a7c37483ad01 ae83af27a2dd a62546ced626 647b436534ed 5971b6ce764f 23cb15b0fcec 9ee13ca3b908]

$ docker run --name mysql-cont -e MYSQL_ROOT_PASSWORD=root -d tenzan/mysql:20151214
Unable to find image 'tenzan/mysql:20151214' locally
20151214: Pulling from tenzan/mysql

9ee13ca3b908: Pull complete
23cb15b0fcec: Pull complete
5971b6ce764f: Pull complete
647b436534ed: Pull complete
a62546ced626: Pull complete
ae83af27a2dd: Pull complete
4cb4f862d994: Pull complete
a7c37483ad01: Pull complete
6838bb2f0679: Pull complete
ca369de2f9aa: Pull complete
61e1545850dc: Pull complete
1dfcc2e5b6c2: Pull complete
8c1c3732f2da: Pull complete
f5f84dea6330: Pull complete
be8cee672400: Pull complete
b01706fbc5a4: Pull complete
756104f7750e: Pull complete
53fa043ba705: Pull complete
6035d8efd4a2: Pull complete
95868108c081: Pull complete
Digest: sha256:b733eb67e4c743a679afb6053104528176940b39b0956854fa7bde13a78ccad0
Status: Downloaded newer image for tenzan/mysql:20151214
de66328a6c0aa1219266d2a3e2047846abf279c9b5ad8c458e0b1384c61e666c

$ docker inspect mysql-cont
[
{
    "Id": "de66328a6c0aa1219266d2a3e2047846abf279c9b5ad8c458e0b1384c61e666c",
    "Created": "2015-12-14T06:27:52.620458564Z",
    "Path": "/entrypoint.sh",
    "Args": [
        "mysqld"
    ],
    "State": {
        "Status": "running",
        "Running": true,
        "Paused": false,
        "Restarting": false,
        "OOMKilled": false,
        "Dead": false,
        "Pid": 8363,
        "ExitCode": 0,
        "Error": "",
        "StartedAt": "2015-12-14T06:27:52.664280933Z",
        "FinishedAt": "0001-01-01T00:00:00Z"
    },
    "Image": "95868108c081ea916ac4f7120952b9db21e8b49f614e8831e5944a6b9369d957",
    "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/de66328a6c0aa1219266d2a3e2047846abf279c9b5ad8c458e0b1384c61e666c/resolv.conf",
    "HostnamePath": "/mnt/sda1/var/lib/docker/containers/de66328a6c0aa1219266d2a3e2047846abf279c9b5ad8c458e0b1384c61e666c/hostname",
    "HostsPath": "/mnt/sda1/var/lib/docker/containers/de66328a6c0aa1219266d2a3e2047846abf279c9b5ad8c458e0b1384c61e666c/hosts",
    "LogPath": "/mnt/sda1/var/lib/docker/containers/de66328a6c0aa1219266d2a3e2047846abf279c9b5ad8c458e0b1384c61e666c/de66328a6c0aa1219266d2a3e2047846abf279c9b5ad8c458e0b1384c61e666c-json.log",
    "Name": "/mysql-cont",
    "RestartCount": 0,
    "Driver": "aufs",
    "ExecDriver": "native-0.2",
    "MountLabel": "",
    "ProcessLabel": "",
    "AppArmorProfile": "",
    "ExecIDs": null,
    "HostConfig": {
        "Binds": null,
        "ContainerIDFile": "",
        "LxcConf": [],
        "Memory": 0,
        "MemoryReservation": 0,
        "MemorySwap": 0,
        "KernelMemory": 0,
        "CpuShares": 0,
        "CpuPeriod": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "CpuQuota": 0,
        "BlkioWeight": 0,
        "OomKillDisable": false,
        "MemorySwappiness": -1,
        "Privileged": false,
        "PortBindings": {},
        "Links": null,
        "PublishAllPorts": false,
        "Dns": [],
        "DnsOptions": [],
        "DnsSearch": [],
        "ExtraHosts": null,
        "VolumesFrom": null,
        "Devices": [],
        "NetworkMode": "default",
        "IpcMode": "",
        "PidMode": "",
        "UTSMode": "",
        "CapAdd": null,
        "CapDrop": null,
        "GroupAdd": null,
        "RestartPolicy": {
            "Name": "no",
            "MaximumRetryCount": 0
        },
        "SecurityOpt": null,
        "ReadonlyRootfs": false,
        "Ulimits": null,
        "LogConfig": {
            "Type": "json-file",
            "Config": {}
        },
        "CgroupParent": "",
        "ConsoleSize": [
            0,
            0
        ],
        "VolumeDriver": ""
    },
    "GraphDriver": {
        "Name": "aufs",
        "Data": null
    },
    "Mounts": [
        {
            "Name": "93ac09c533e4c609ce17e78ac5460a52c9d0f7343458d2113af7396e2dac4670",
            "Source": "/mnt/sda1/var/lib/docker/volumes/93ac09c533e4c609ce17e78ac5460a52c9d0f7343458d2113af7396e2dac4670/_data",
            "Destination": "/var/lib/mysql",
            "Driver": "local",
            "Mode": "",
            "RW": true
        }
    ],
    "Config": {
        "Hostname": "de66328a6c0a",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "ExposedPorts": {
            "3306/tcp": {}
        },
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "MYSQL_ROOT_PASSWORD=root",
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "MYSQL_MAJOR=5.7",
            "MYSQL_VERSION=5.7.9-1debian8",
            "DB_NAME=catalog",
            "DB_USER=root",
            "DB_PASS=root"
        ],
        "Cmd": [
            "mysqld"
        ],
        "Image": "tenzan/mysql:20151214",
        "Volumes": {
            "/var/lib/mysql": {}
        },
        "WorkingDir": "",
        "Entrypoint": [
            "/entrypoint.sh"
        ],
        "OnBuild": null,
        "Labels": {},
        "StopSignal": "SIGTERM"
    },
    "NetworkSettings": {
        "Bridge": "",
        "SandboxID": "c4d2fdca2afff185daa324578b21ac2ecf1348f1e739a2822a00586b8c4c0650",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {
            "3306/tcp": null
        },
        "SandboxKey": "/var/run/docker/netns/c4d2fdca2aff",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null,
        "EndpointID": "da6bc29cf275ad274df2c7710dfd0c9c6ef7398114b11c50fb1482e5f81e5841",
        "Gateway": "172.17.0.1",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAddress": "172.17.0.2",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",
        "MacAddress": "02:42:ac:11:00:02",
        "Networks": {
            "bridge": {
                "EndpointID": "da6bc29cf275ad274df2c7710dfd0c9c6ef7398114b11c50fb1482e5f81e5841",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.2",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:11:00:02"
            }
        }
    }
}
]

$ docker run -it --link sql:mysql-cont --rm tenzan/mysql:20151214 sh -c 'exec mysql -hsql -uroot -p'
Error response from daemon: Could not get container for sql

(Anoop) #8

OK, I could reproduce the same issue as you’ve been facing. But it occurs only in a virtualbox/docker-machine env. Not sure if it is a bug or something I may be missing.

In any event, this worked for me. Please try it on your end and let me know:

 docker network create red
 docker network connect red mysql-cont
 docker run -it --net=red --rm tenzan/mysql:20151214 sh -c 'exec mysql -hmysql-cont -uroot -proot'

What I’m doing is using docker’s (somewhat) new networking model instead of links. The network I create called red is shared by the hosts mysql-cont and the new one created for the client, such that they can ping each other.


(Oscar) #9

Wow, Anoop, thanks a lot!

This was something new to me! :smile:

How about docker exec -it mysql-cont bash ? Is it still same at the moment? Or there’s a better way, same way with docker network stuff you showed?


(Anoop) #10

Yes, that would work except that this would expect bash to be installed and available in the path. In official images, in order to keep the image size small & to conform to good practices bash may not be available (usually). In your image (tenzan/mysql), it seems to work, with the caveat that you would need to be on the same host as where the container was started.


(Oscar) #11

So, how would I connect a container if there’s no bash shell?


(Anoop) #12

bash / sh is just a medium to connect to the underlying process (mysql in this particular case. In other words bash / sh is a means to an end which is to get to your mysql> prompt. Containers should ideally run only one service / process, so that means all that your mysql container is running is just mysqld and if you want to connect to it you can use another container for that purpose (like how we did here) and not over bash. If you want to troubleshoot, you would want to use docker logs and docker inspect. Having bash there would just serve as a crutch in my opinion.


(Oscar) #13

Thanks a lot, Anoop. :wink:


(Anoop) #14

It was my pleasure. Thank you!