Docker: Unterschied zwischen den Versionen

Aus robopagex.com
Zur Navigation springen Zur Suche springen
Zeile 74: Zeile 74:
  
 
     $''' docker run --help'''
 
     $''' docker run --help'''
 +
    $''' docker run -d --TABTAB'''
  
 
''docker run [OPTIONS] IMAGE [COMMAND] [ARG...]''
 
''docker run [OPTIONS] IMAGE [COMMAND] [ARG...]''
Zeile 79: Zeile 80:
 
     '''-it'''                  # interactively
 
     '''-it'''                  # interactively
 
     '''-d'''                    # detached
 
     '''-d'''                    # detached
 +
    '''---ip 172.17.0.2 '''    # Set Network first, only ip not work
 +
    '''--hostname'''            # aaaa.de
 +
    '''-p 172.17.0.2:1010:80''' # define external port and ip
 
     '''-p 8080:80'''            # define external port
 
     '''-p 8080:80'''            # define external port
 
     '''--name MYNAME'''        # define container name
 
     '''--name MYNAME'''        # define container name
Zeile 88: Zeile 92:
 
     '''-w="/home"'''            # ^
 
     '''-w="/home"'''            # ^
 
     '''-v source:target'''      # Mount or bind Volume/Directory
 
     '''-v source:target'''      # Mount or bind Volume/Directory
 
+
                  '''-v Apache:/var/www/html '''
 +
                  '''-v "$PWD":/var/www/html'''
  
 
''run alpine cli sh''
 
''run alpine cli sh''

Version vom 15. Juni 2021, 08:31 Uhr

Docker Container & Images

[Docker https://www.docker.com/]


Tutorial docker cli, docker-compose, docker swarm

Docker cli

Version

   $ docker -v
   $ docker-compose -v

System

system-wide information

   $ docker system info 

docker disk usage

   $ docker system df 

real time events from the server

   $ docker system events


Status

running containers

   $ docker ps
   $ docker ps --all
   $ docker ps -a

real time status

   $ docker stats
   $ docker top [CONTAINER]


Images

View all Images

   $ docker images
   $ docker image list

View Image by name

   $ docker images alpine
   $ docker images history [IMAGENAME]
   $ docker images --digests

Image commands

   $ docker image
   build        #
   history      #
   import       #
   inspect      #
   load         #
   ls           #
   prune        #
   pull         #
   push         #
   rm           #
   save         #
   tag          #

Export

export container, these commands has the same result

   $ docker export nginx > nginx_latest.tar
   $ docker export --output="nginx_latest" nginx

docker bash run images

   $ docker run --help
   $ docker run -d --TABTAB

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

   $ docker run 
   -it                   # interactively
   -d                    # detached
   ---ip 172.17.0.2      # Set Network first, only ip not work
   --hostname            # aaaa.de
   -p 172.17.0.2:1010:80 # define external port and ip
   -p 8080:80            # define external port
   --name MYNAME         # define container name
   -m 300m               # memory limit 
   --memory-swap 1g      #
   --cpuset-cups="1"     # 
   -rm                   # auto remove container after exit
   --workdir "/home"     # Any RUN , CMD , ADD , COPY , or ENTRYPOINT command will be executed in the specified working directory
   -w="/home"            # ^
   -v source:target      # Mount or bind Volume/Directory
                 -v Apache:/var/www/html 
                 -v "$PWD":/var/www/html

run alpine cli sh

   $ docker run -it alpine /bin/sh

run alpine cli detached

   $ docker run -it -d --name MYALPINE -p 8080:80 alpine

run alpine cli with entrypoint

   $ docker run -it --name MYALPINE -p 8080:80 --entrypoint /bin/sh alpine
   $ docker run -it --name MYALPINE -p 8080:80 --entrypoint /bin/sh alpine

EXEC

   $ docker exec -it [container-name/id] /bin/sh

Volume/Directory

   $ docker run -it --name MYALPINE -v ${PWD}:/home alpine
   $ docker run -it --name MYALPINE -w='/home' -v ${PWD}:/home alpine
   $ docker run -it --name MYALPINE --entrypoint /bin/sh --workdir '/home' -v ${PWD}:/home alpine

docker bash stop/kill images

   $ docker stop [CONTAINER]
   $ docker kill [CONTAINER]

docker File

docker compose