Docker Alpine

作者: JaedenKil | 来源:发表于2021-11-19 16:37 被阅读0次
    1. Pull Alpine
    docker pull alpine
    
    1. Run Alpine commands
    $ docker run -it --rm alpine /bin/ash
    / # whoami
    root
    / #
    
    • /bin/ash is Ash (Almquist Shell) provided by BusyBox
    • --rm Automatically remove the container when it exits (docker run --help)
    • -i Interactive mode (Keep STDIN open even if not attached)
    • -t Allocate a pseudo-TTY
    1. Start a docker image with a name in interactive shell mode
    docker run --name MH -it alpine /bin/ash
    
    / # whoami
    root
    
    / # mkdir TestDir
    
    1. Check containers
    $ docker ps -a
    CONTAINER ID   IMAGE     COMMAND                 CREATED          STATUS                      PORTS     NAMES
    385f6532da25   alpine    "/bin/ash"              3 minutes ago    Up 2 minutes                          MH
    
    1. Run the container
    $ docker exec -it MH /bin/ash
    
    / # ls -al TestDir/
    total 8
    drwxr-xr-x    2 root     root          4096 Nov 19 08:32 .
    drwxr-xr-x    1 root     root          4096 Nov 19 08:32 ..
    

    Reference: https://docs.docker.com/engine/reference/commandline/exec/


    Reference: https://docker-curriculum.com/

    Commands:

    1. Check docker images:
    docker images
    
    1. Run commands
    $ docker run alpine echo "Hello Alpine"
    Hello Alpine
    
    1. Check running containers
    $ docker ps -a
    CONTAINER ID   IMAGE           COMMAND                 CREATED          STATUS                        PORTS     NAMES
    53eae49a4afa   alpine          "echo 'Hello Alpine'"   52 seconds ago   Exited (0) 51 seconds ago               stoic_bohr
    93e88e70e838   ubuntu:latest   "bash"                  2 months ago     Exited (255) 12 minutes ago             admiring_wright
    909907b45f5a   ubuntu          "bash"                  2 months ago     Exited (0) 2 months ago                 serene_joliot
    0b4e542857be   ubuntu          "bash"                  2 months ago     Exited (0) 2 months ago                 amazing_knuth
    
    1. Remove containers
    $ docker rm 93e88e70e838 909907b45f5a 0b4e542857be
    93e88e70e838
    909907b45f5a
    0b4e542857be
    

    相关文章

      网友评论

        本文标题:Docker Alpine

        本文链接:https://www.haomeiwen.com/subject/drqetrtx.html