<p>As the <a href="https://docs.docker.com/engine/reference/run/" rel="nofollow noreferrer">documentation</a> clearly states <code>docker run</code> command should be invoked as follows:</p>
<pre><code>docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
</code></pre>
<p>so when you run</p>
<pre><code>docker run mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password
</code></pre>
<p>Docker assumes <code>-p 3306:3306 -e MYSQL_ROOT_PASSWORD=password</code> is a command you want to run inside the container, not a list of options for <code>docker run</code> command.</p>
<p>The proper <code>docker run</code> invocation with the parameters you specified is:</p>
<pre><code>docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password mysql
</code></pre>

CC BY-SA 4.0
2020-09-01T20:17:30.313Z
2020-09-01T20:17:30.313Z
Konrad Botor
<p>Just getting started, want to run the <strong>downloaded</strong> version of <code>mysql</code>:</p>
<pre><code>root:~# 
root:~# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
basex/basexhttp      latest              3339bf6bc898        4 days ago          226MB
twilio/twilio-java   latest              611ab7ece1cf        12 days ago         993MB
mysql                latest              0d64f46acfd1        3 weeks ago         544MB
jetty                latest              5f997007f18d        4 weeks ago         522MB
hello-world          latest              bf756fb1ae65        8 months ago        13.3kB
root:~# 
root:~# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the &quot;hello-world&quot; image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

root:~# 
root:~# docker run mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password 
2020-09-01 06:53:03+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
2020-09-01 06:53:03+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
    command was: mysqld -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password --verbose --help
    Enter password: mysqld: Can not perform keyring migration : Invalid --keyring-migration-source option.
2020-09-01T06:53:03.366882Z 0 [ERROR] [MY-011084] [Server] Keyring migration failed.
2020-09-01T06:53:03.368621Z 0 [ERROR] [MY-010119] [Server] Aborting
root:~# 
</code></pre>
<p>Without <a href="https://stackoverflow.com/q/33795923/4531180">re-downloading</a> the image.</p>

<docker><containers><images><mysql><passwords>
how to send a password to MySQL with docker?
Nicholas Saunders
# how to send a password to MySQL with docker?

(Asked by: username_0 on 2020-09-01)

Just getting started, want to run the downloaded version of mysql:
root:~# 
root:~# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
basex/basexhttp      latest              3339bf6bc898        4 days ago          226MB
twilio/twilio-java   latest              611ab7ece1cf        12 days ago         993MB
mysql                latest              0d64f46acfd1        3 weeks ago         544MB
jetty                latest              5f997007f18d        4 weeks ago         522MB
hello-world          latest              bf756fb1ae65        8 months ago        13.3kB
root:~# 
root:~# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

root:~# 
root:~# docker run mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password 
2020-09-01 06:53:03+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
2020-09-01 06:53:03+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
    command was: mysqld -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password --verbose --help
    Enter password: mysqld: Can not perform keyring migration : Invalid --keyring-migration-source option.
2020-09-01T06:53:03.366882Z 0 [ERROR] [MY-011084] [Server] Keyring migration failed.
2020-09-01T06:53:03.368621Z 0 [ERROR] [MY-010119] [Server] Aborting
root:~# 

Without re-downloading the image.

**Tags:** docker, containers, images, mysql, passwords


---

## 1 answers

### Answer by username_1 on 2020-09-01. Score: 4 | Accepted answer

As the documentation clearly states docker run command should be invoked as follows:
docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]

so when you run
docker run mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password

Docker assumes -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password is a command you want to run inside the container, not a list of options for docker run command.
The proper docker run invocation with the parameters you specified is:
docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password mysql


---

