Handling Docker at console

Aus xinux.net
Zur Navigation springen Zur Suche springen

Docker run an image

  • docker run -d -p 8480:80 -p 8443:443 -v /data/docker/apache_html:/var/www/html -v /data/docker/apache_etc:/etc/apache2 --name co-apache im-apache-03
Options
-d demon mode
-p 8480:80 host port 8480 to container port 80
-p 8443:443 host port 8443 to container port 443
-v /data/docker/apache_html:/var/www/html mount /data/docker/apache_html on host to var/www/html in the container
-v /data/docker/apache_etc:/etc/apache2 mount /data/docker/apache_etc on host /etc/apache2 in the container
--name co-apache name of the container
im-apache-03 name of the image

show the running container

  • docker ps
CONTAINER ID      IMAGE              COMMAND                  CREATED             STATUS                PORTS                                         NAMES
d12860279ef5      im-apache-03       "bash /start.sh"         11 minutes ago      Up 11 minutes         0.0.0.0:8480->80/tcp, 0.0.0.0:8443->443/tcp   co-apache

stop a container

  • docker stop co-apache

start a container

  • docker start co-apache

restart a container

  • docker restart co-apache

start a bash in a running container

  • docker exec -it co-apache bash

show logging from the container

  • docker logs co-apache
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message

inspect a container

  • docker inspect co-apache
[
    {
        "Id": "d12860279ef50695be7d681afa04cf60c7499eb79f84a6dd0c058bdbcfe3b625",
        "Created": "2019-10-08T13:33:29.17566633Z",
        "Path": "bash",
        "Args": [
            "/start.sh"
        ],
...
...
...