How to 'docker run mysql' and attach (login into) container to see cpu, memory, logs,

Hello,

I’d like to do ‘docker run mysql’ and attach (login into) container to see everything looks fine
such as cpu, memory, data file size, logs and need to run some sql statement on mysql>
Do you have any suggestion?

very simple Dockferfile

FROM moonsyim/amazon-linux-ami-mysql-20150630:0.2
EXPOSE 3306
CMD [“mysqld”,"–user=root"]

  1. docker run -i -t -d -p 3306:3306 moonsyim/amazon-linux-ami-mysql-20150630:0.3 /bin/bash
    –> attachable, but mysql is not started, so need to start manually

  2. docker run -i -t -p 3306:3306 moonsyim/amazon-linux-ami-mysql-20150630:0.3 /bin/bash
    –> attachable, but mysql is not started, so need to start manually

  3. docker run -i -t -d -p 3306:3306 moonsyim/amazon-linux-ami-mysql-20150630:0.3
    –> not attachable.

  4. docker run -d -p 3306:3306 moonsyim/amazon-linux-ami-mysql-20150630:0.3 /bin/bash --> Exited(0)

  5. docker run -p 3306:3306 moonsyim/amazon-linux-ami-mysql-20150630:0.3 /bin/bash --> Exited(0)

  6. docker run -i -t -p 3306:3306 moonsyim/amazon-linux-ami-mysql-20150630:0.3
    –> automatically attached, but no shell, ctrl+P, ctrl+Q works, but from this point, no attachable

what you look for is docker exec, for example docker exec -it container_id bash
see the doc
http://docs.docker.com/reference/commandline/exec/

You also have
docker top container_id
the doc
http://docs.docker.com/reference/commandline/top/
and docker stat
the doc
http://docs.docker.com/reference/commandline/stats/

oh, that’s correct, thanks a lot k3ck3c !!!.