Linux

Docker Alpine

2021-11-19  本文已影响0人  JaedenKil
  1. Pull Alpine
docker pull alpine
  1. Run Alpine commands
$ docker run -it --rm alpine /bin/ash
/ # whoami
root
/ #
  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
上一篇下一篇

猜你喜欢

热点阅读