Ubuntu docker user guide
-
Check your linux system whether installed docker, if done skip this step.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null apt update apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Non-root users need to add sudo prefix. This operation is complicated. Now use the following operation to remove it.
sudo groupadd docker sudo gpasswd -a ${USER} docker sudo systemctl restart docker exit or open a new terminal shell
Run hello-world image
coolpi@coolpi:~$ docker version Client: Docker Engine - Community Version: 20.10.22 API version: 1.41 Go version: go1.18.9 Git commit: 3a2c30b Built: Thu Dec 15 22:27:17 2022 OS/Arch: linux/arm64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.22 API version: 1.41 (minimum version 1.12) Go version: go1.18.9 Git commit: 42c8b31 Built: Thu Dec 15 22:25:29 2022 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.14 GitCommit: 9ba4b250366a5ddde94bb7c9d1def331423aa323 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0 coolpi@coolpi:~$ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 7050e35b49f5: Pull complete Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (arm64v8) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/ coolpi@coolpi:~$
-
Build a docker image with Dockerfile
$ cat Dockerfile FROM ubuntu:20.04 MAINTAINER JACK<jack@cool-pi.com> #RUN sed -i s@/ports.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list \ && apt-get clean RUN apt-get update ENV DEBIAN_FRONTEND=noninteractive RUN apt-get install -y build-essential chrpath vim expect git curl dialog tzdata locales iputils-ping net-tools ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN locale-gen en_US.UTF-8 && DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales ENV LANG=en_US.UTF-8 ENV LANGUAGE=en_US.UTF-8 ENV LC_ALL=en_US.UTF-8 RUN locale-gen en_US RUN useradd coolpi;\ adduser coolpi sudo;\ mkdir -p /home/coolpi;\ chown coolpi:coolpi -R /home/coolpi;\ echo coolpi:coolpi | chpasswd; #CMD su -l coolpi #CMD "/bin/bash"
$ docker build -t my-ubuntu:20.04 --rm=true . ...