Quick start to install Docker and Docker-compose on Linux

CentOS

# (optional) remove old
sudo yum remove -y docker \
                  docker-ce-cli \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
                  
# Docker              
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
  
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    
sudo yum install -y docker-ce


sudo systemctl start docker
sudo systemctl enable docker  # start docker at boot up

# (optional) Verify
sudo docker run hello-world

Install docker-compose

# Dcoker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose


# (optional) Verify
docker-compose --version

Advenced

# Move fat docker to other folder with symlink - Linux (bash)
sudo systemctl stop docker
sudo mv /var/lib/docker /data/.
sudo ln -s /data/docker /var/lib/docker
sudo systemctl start docker

# Move fat docker to other folder with symlink - Windows (Powershell)
move C:\ProgramData\docker\* D:\ProgramData\docker
cmd /c mklink /d C:\ProgramData\docker D:\ProgramData\docker


# Add default Log rotation
sudo bash -c 'cat >> /etc/docker/daemon.json' << EOF
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "512"
  }
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

# Execute docker without sudo
sudo groupadd docker
sudo usermod -aG docker $USER
#> Re-login to apply

# Show other docker version
yum list docker-ce --showduplicates | sort -r

# Restart 
## daemon
sudo systemctl daemon-reload
## docker service
sudo systemctl restart docker.service
## docker
sudo systemctl restart docker

# Remove stuff
docker container prune    # Remove all stopped containers
docker volume prune     # Remove all unused volumes
docker image prune     # Remove unused images
docker system prune     # All of the above, in this order: containers, volumes, images
docker ps -a -q | % { docker rm $_ }     # Remove container with PowerShell
docker rm $(docker ps -a -q)     # Remove container with Bash
docker volume rm $(docker volume ls -f dangling=true -q)

Ubuntu

# (optional) Remove old
sudo apt-get remove -y docker-ce docker-ce-cli docker docker-engine docker.io containerd runc

# Setting up
sudo apt-get update
sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

## (optional) Verify fingerprint 
sudo apt-key fingerprint 0EBFCD88

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

# Install latest
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

## (optional) Install other version.  PS."18.09 no need to install docker-ce-cli"
apt-cache madison docker-ce
sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

# (optional) Verify
sudo docker run hello-world

98 Comments

  1. It is the best time to make some plans for the future and it is time to be happy.
    I have read this post and if I could I want to suggest you few interesting things or tips.
    Perhaps you can write next articles referring to this article.
    I want to read even more things about it!

  2. I’m really enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more enjoyable
    for me to come here and visit more often. Did you hire out a developer
    to create your theme? Fantastic work!

  3. Thank you a bunch for sharing this with all of us you actually recognize what you are talking approximately!
    Bookmarked. Please also consult with my web site =).
    We could have a hyperlink exchange agreement between us

  4. Thanks for the marvelous posting! I quite enjoyed reading it, you can be a great author.
    I will make sure to bookmark your blog and will often come back from now on. I want to encourage one to continue your great
    job, have a nice holiday weekend!

  5. I know this if off topic but I’m looking into starting my own weblog and was curious what all is
    needed to get setup? I’m assuming having a blog like yours
    would cost a pretty penny? I’m not very internet smart
    so I’m not 100% sure. Any suggestions or advice would be greatly appreciated.
    Cheers

  6. I’m really loving the theme/design of your site. Do you ever run into any
    browser compatibility problems? A few of my blog readers have complained about my blog not
    operating correctly in Explorer but looks great in Opera.
    Do you have any solutions to help fix this issue?

  7. I simply could not leave your web site before suggesting
    that I extremely enjoyed the usual info an individual provide to your visitors?
    Is gonna be again steadily in order to check up on new posts

  8. Aw, this was an exceptionally good post. Taking the time and actual effort to produce a top notch article… but what can I say… I put things off a lot and don’t seem to get anything done.

  9. What i don’t realize is in fact how you are not actually much more well-appreciated than you may be now.
    You’re so intelligent. You already know thus significantly relating to this subject, made me
    in my view consider it from numerous varied angles.

    Its like men and women are not fascinated unless it’s one
    thing to do with Lady gaga! Your personal stuffs excellent.
    All the time take care of it up!

  10. Hey just wanted to give you a quick heads up. The words in your post seem to be running off
    the screen in Ie. I’m not sure if this is a formatting issue or something to do with web browser compatibility but I figured I’d post to let you
    know. The layout look great though! Hope you get the issue resolved soon. Cheers

  11. I have been surfing online more than 4 hours today,
    yet I never found any interesting article like yours.
    It is pretty worth enough for me. Personally, if all site owners
    and bloggers made good content as you did, the net will be much more useful than ever before.

  12. Hello, i feel that i saw you visited my weblog thus i came to go back the choose?.I’m attempting
    to in finding things to enhance my website!I assume its ok to use some of your concepts!!

  13. I know this if off topic but I’m looking into starting my own blog and was wondering what all
    is needed to get set up? I’m assuming having a blog
    like yours would cost a pretty penny? I’m not very internet smart so I’m not 100% sure.
    Any tips or advice would be greatly appreciated. Kudos

  14. Link exchange is nothing else however it is simply placing
    the other person’s web site link on your page at suitable place and other person will also do same in favor of
    you.

  15. Hi there just wanted to give you a quick heads up.
    The words in your post seem to be running off the screen in Internet explorer.
    I’m not sure if this is a format issue or something to do with
    web browser compatibility but I thought I’d post to let
    you know. The style and design look great though!
    Hope you get the problem solved soon. Thanks

  16. Excellent beat ! I would like to apprentice while you amend your website,
    how could i subscribe for a blog website? The account
    helped me a acceptable deal. I had been tiny bit
    acquainted of this your broadcast provided bright clear concept

  17. Pg สล็อต เว็บตรง ทาง เข้า เล่น เล่น พีจีสล็อต ที่ครอบครองใจคนทั่วทั้งประเทศสูงที่สุด เพราะว่ามีเกมออนไลน์จากค่ายชั้นหนึ่งมากมายก่ายกอง ให้เลือกเล่นพนันบนเว็บไซต์ไซต์

Leave a Reply

Your email address will not be published.