Code Monkey home page Code Monkey logo

cursodocker's Introduction

Docker

Install Docker

sudo apt-get update

# install container runtime
sudo apt-get install -y gnupg2 software-properties-common ca-certificates
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y containerd.io docker-ce docker-ce-cli

sudo mkdir -p /etc/systemd/system/docker.service.d

sudo tee /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl enable docker

sudo sysctl --system

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get update
sudo apt-get install -y containerd.io

sudo mkdir -p /etc/containerd

containerd config default  /etc/containerd/config.toml
sudo systemctl restart containerd
sudo systemctl enable containerd

Settings

#sudo groupadd docker
sudo usermod -aG docker $USER

sudo chmod 666 /var/run/docker.sock

Commands

Basic commands

docker run hello-world

docker pull alpine
docker pull alpine:3.7
docker run -it alpine:3.7 sh

docker ps
docker exec -it ba50145aa61b sh

Util commands

#process docker in status
docker stats

#excecute with environment variable
docker exec -e "TERM=xterm-256color" -w /workspace -it devcontainer bash

Images

docker run -ti ubuntu /bin/bash
docker ps -a | head
docker commit 6a15bc5c383f
docker image ls

docker image tag 6a15bc5c383f mydocker
docker commit d4f361137c7b
docker tag d4f361137c7b mydocker:1.1
docker run mydocker figlet hellow

docker build -t mydocker:1.2 .
docker run mydocker:1.2 figlet hellow
docker image history 0e3d2e901a67

Volumes

docker run -d nginx:1.15.7
docker ps
docker exec -it ad1b98d0d7e5 bash
docker stop ad1b98d0d7e5
docker run -v /root/notes/3.docker/index.html:/usr/share/nginx/html/index.html:ro -d nginx:1.15.7
docker ps
docker exec -it 924ef99d8a08 bash

docker ps
docker stop 924ef99d8a08
docker run -v /root/notes/3.docker/index.html:/usr/share/nginx/html/index.html:ro -d -p 8889:80 nginx:1.15.7

Docker-Compose

docker run -e MYSQL_ROOT_PASSWORD=mypass -e MYSQL_DATABASE=mydb -v /root/notes/4.docker/mysql-data:/var/lib/mysql -d mysql:8.0.13

docker-compose up -d
docker ps

Networking

#create network
docker network create --subnet 10.1.0.0/16 --gateway 10.1.0.1 --ip-range 10.1.4.0/24 devops_bridge

#connect docker to network
docker network connect devops_bridge hhtpd
docker network connect devops_bridge proxy
docker inspect devops_bridge

#list network for dockers
docker network ls

Clean

#clear docker not used
docker system prune

#remove all images
docker rmi $(docker images -a -q)

Export and Import

#export docker
docker export api_1 > api.tar #api_1 is name docker

#import docker
docker import api.tar

Inspect

docker image inspect --format '{{json .}}' mongo-express | jq

cursodocker's People

Contributors

mt2h avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.