Skip to content

space25/Docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

128 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker

Install Docker:

  1. Install Docker CE for Ubuntu

    sudo snap install docker
    
  2. [Optional] Add GPU support:

  3. Post-installation steps for Linux

    sudo groupadd docker # Create the docker group.
    
    sudo usermod -aG docker $USER # Add your user to the docker group.
    
  4. Verify that Docker CE is installed correctly by running the Ubuntu image:

     docker run docker/whalesay cowsay "HI $(docker --version)"
    
  5. Get started with Docker

Operation with docker

  • Run a container in an interactive mode:

      docker run -it ubuntu bash
    
  • To check are running containers:

      docker ps
    
  • Check containers:

      docker ps -a
    
  • Check images:

      docker images
    
  • Execute command in container:

      docker exec -it <id> /bin/bash
    
  • Build a image:

      docker build --network host -t '<name>':'<version>' .
    
  • Exit from a container without stopping it:

      CTRL + P + Q
    
  • Stop a container from outside of the container:

      docker stop <container id or name>
    
  • Kill a container from outside of the container

      docker kill <container id or name>
    
  • Restart a container:

      docker start <container id>
    
  • Attach to a container:

      docker attach <container id>
    
  • Create an image from a container:

      docker commit <container id> <image name>
    
  • Purging All Unused or Dangling Images, Containers, Volumes, and Networks

    Docker provides a single command that will clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container):

      docker system prune
    

    To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command:

      docker system prune -a
    
  • Port mapping:

      docker run -d -p 5001:80
    
      docker run -it -p 8885:8888 <name>
    
  • Volume mapping:

      docker run -it -v ~/Downloads:/data ubuntu /bin/bash
    
  • Container logs in a detach mode:

      docker logs <container_d>
    
  • Other:

    '-d' run in the background

    '-it' launch interactive mode

    Path to docker containers /var/lib/docker/aufs/diff/. Docker files

      sudo ls -l /var/lib/docker/aufs/diff/
    

[Optional] Add support aarch64

  • Install QEMU:
    sudo apt update -y && sudo apt upgrade -y && sudo apt install -y qemu-kvm bridge-utils libvirt-daemon virt-manager \
    libvirt-clients libvirt-daemon-system qemu binfmt-support qemu-user-static
    
    sudo adduser $USER libvirt
    
  • Enable support for aarch64 containers on your x86 workstation (This step will execute the registering scripts):
    docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
    
  • Testing the emulation environment:
    docker run --rm -t arm64v8/ubuntu uname -m # Testing the emulation environment
    
    #aarch64
  • Run ubuntu 24.04 aarch64 dicker:
    docker run -it -p 1022:22 --platform linux/arm64/v8 ubuntu:24.04 bash
    

Links

  1. 15 Docker Commands Beginners Should Know
  2. Docker Tutorial for Beginners - A Full DevOps Course on How to Run Applications in Containers
  3. Running and Building ARM Docker

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published