Docker

Configure Docker

  • Prepare a Linux operating system computer
    Here we take the Debian system as an example

  • Install Docker Since we need Aliyun script to install Docker with one click

we have to do these things:

  1. Use Aliyun mirror
    sudo vim /etc/apt/sources.list
    write the following
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
  1. Install
sudo curl -fsSl https://get.docker.com | bash -s docker --mirror Aliyun

If you don’t have curl, you can try again after using this command:

sudo apt-get update
sudo apt-get install curl
  1. Accelerate with Aliyun image
    Go to Alibaba Cloud official website to find mirror acceleration
    Follow the above prompts to configure

Basic use of docker

  • image
# This command is to search for mirror images, limit n means to limit the number of searched images to n
docker search [mirror name] [--limit n]

# Pull the image from DockerHub to the local
docker image pull [mirror name]

# Pull and run a mirror image, the command runs successfully and returns the container number
# -d  Indicates starting as a daemon
# -it Start in interactive mode and can be followed by a path to a terminal as an argument
# -p  Specify port mapping
# -P  port random mapping
docker run [-it] [mirror name]

# Show all local mirrors
docker image ls
docker images

# Display the id of the local mirror
docker image -q
  • build image
# Default use pwd Dockefile
docker built -t <name> .
FROM 
CMD []
ENV VERSION=12.0.16
COPY ./start.sh /app/start.sh
VOLUME [/app]
RUN /bin/bash -c echo "app loaded"
WORKDIR /app
ENTRYPOINT ["/app/start.sh"]
  • Dcoker compose
# Default use pwd docker-compose.yaml