• Recent
    • Docs
    • Github
    • 百度网盘
    • Onedrive
    • Official
    • Shop
    • Register
    • Login

    Ubuntu docker user guide

    Scheduled Pinned Locked Moved Ubuntu
    2 Posts 1 Posters 193 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 大法师大
      大法师
      last edited by 大法师

      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:~$
      

      jack@cool-pi.com

      1 Reply Last reply Reply Quote 0
      • 大法师大
        大法师
        last edited by


        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 .
        ...
        

        jack@cool-pi.com

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post