<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bruner</title>
    <description>The latest articles on DEV Community by Bruner (@rodrigobruner).</description>
    <link>https://dev.to/rodrigobruner</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F899513%2Faf943e94-7913-488d-8c70-285334057ae2.png</url>
      <title>DEV Community: Bruner</title>
      <link>https://dev.to/rodrigobruner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rodrigobruner"/>
    <language>en</language>
    <item>
      <title>How to install Docker on Amazon Linux 2</title>
      <dc:creator>Bruner</dc:creator>
      <pubDate>Thu, 28 Jul 2022 15:47:00 +0000</pubDate>
      <link>https://dev.to/rodrigobruner/how-to-install-docker-on-amazon-linux-2-1na4</link>
      <guid>https://dev.to/rodrigobruner/how-to-install-docker-on-amazon-linux-2-1na4</guid>
      <description>&lt;p&gt;How do I install docker and docker-compose on Amazon Linux 2 running on the EC2 or Lightsail cloud instance?&lt;/p&gt;

&lt;p&gt;Before you read this article, consider using &lt;a href="https://aws.amazon.com/fargate/" rel="noopener noreferrer"&gt;AWS Fargate&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First step is to access the operating system with SSH. This step depends on how your machine is configured. I'll show two options to get access:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;SSH with a private key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i /path/to/the/key.pem ec2-user@ec2-ip-address-dns-name-here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh ec2-user@ec2-ip-address-dns-name-here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Apply pending updates using the &lt;a href="https://access.redhat.com/articles/yum-cheat-sheet" rel="noopener noreferrer"&gt;yum command&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum update
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Search for Docker package:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum search docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install docker with the command below:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add group membership for the default "ec2-user" so you can run all docker commands.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo usermod -a -G docker ec2-user
id ec2-user
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enable docker service at boot time:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable docker.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start the Docker service:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start docker.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check docker service status, run:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status docker.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The expected return would be something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;● docker. Service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-09-08 05:03:52 EDT; 18s ago
     Docs: https://docs.docker.com
  Process: 3295 ExecStartPre=/usr/libexec/docker/docker-setup-runtimes.sh (code=exited, status=0/SUCCESS)
  Process: 3289 ExecStartPre=/bin/mkdir -p /run/docker (code=exited, status=0/SUCCESS)
 Main PID: 3312 (dockerd)
    Tasks: 9
   Memory: 39.9M
   CGroup: /system.slice/docker.service
           └─3312 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/c...

Sep 08 05:03:51 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Sep 08 05:03:51 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Sep 08 05:03:51 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Sep 08 05:03:51 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Sep 08 05:03:52 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Sep 08 05:03:52 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Sep 08 05:03:52 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Sep 08 05:03:52 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Sep 08 05:03:52 amazon.example.local systemd[1]: Started Docker Applicatio...
Sep 08 05:03:52 amazon.example.local dockerd[3312]: time=2021-09-08T05:03...
Hint: Some lines were ellipsized, use -l to show in full.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Check the Docker version:

&lt;code&gt;
docker version
&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The return would be something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client:
 Version:           20.10.13
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 31 19:20:32 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.13
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       906f57f
  Built:            Thu Mar 31 19:21:13 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.13
  GitCommit:        9cc61520f4cd876b86e77edfeb88fbcd536d1f9d
 runc:
  Version:          1.0.3
  GitCommit:        f46b6ba2c9314cfc8caae24a32ec5fe9ef1059fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Need docker-compose too?
&lt;/h3&gt;

&lt;p&gt;You have two alternatives to install. See below: &lt;/p&gt;

&lt;p&gt;Install using &lt;a href="https://pip.pypa.io/en/stable/" rel="noopener noreferrer"&gt;pip&lt;/a&gt; (&lt;em&gt;recommended&lt;/em&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo pip3 install docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;OR&lt;/strong&gt;Manually install&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) 
sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/local/bin/docker-compose
sudo chmod -v +x /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To verify that the installation was successful, can you use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Should you see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose version 1.29.2, build unknown
docker-py version: 5.0.3
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.0.2k-fips  26 Jan 2017
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Bonus: install ctop
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/bcicen/ctop" rel="noopener noreferrer"&gt;ctop&lt;/a&gt; provides a concise and condensed overview of real-time metrics for multiple containers. &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fbcicen%2Fctop%2Fmaster%2F_docs%2Fimg%2Fgrid.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fbcicen%2Fctop%2Fmaster%2F_docs%2Fimg%2Fgrid.gif" alt="ctop"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-linux-amd64 -O /usr/local/bin/ctop
sudo chmod +x /usr/local/bin/ctop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That tip was given by &lt;a href="https://dev.to/marcelomichels"&gt;@marcelomichels&lt;/a&gt;; thanks!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
