<?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: Hojjat-1</title>
    <description>The latest articles on DEV Community by Hojjat-1 (@hojjat12).</description>
    <link>https://dev.to/hojjat12</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%2F794021%2F9869a725-c0d0-43de-b73d-e584187ae136.png</url>
      <title>DEV Community: Hojjat-1</title>
      <link>https://dev.to/hojjat12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hojjat12"/>
    <language>en</language>
    <item>
      <title>Deploy Redis as a Docker container [part 1]</title>
      <dc:creator>Hojjat-1</dc:creator>
      <pubDate>Fri, 14 Jan 2022 22:29:47 +0000</pubDate>
      <link>https://dev.to/hojjat12/deploy-redis-as-a-docker-container-part-1-5c48</link>
      <guid>https://dev.to/hojjat12/deploy-redis-as-a-docker-container-part-1-5c48</guid>
      <description>&lt;p&gt;&lt;a href="https://redis.io"&gt;Redis&lt;/a&gt; is an in-memory key-value store which can save abstract data structures with high performance. The open-source software is typically used for database, messaging, and caching functions.&lt;/p&gt;

&lt;p&gt;Docker is the leading toolkit for packaging applications into containers. It lets you isolate software components into independent environments with their own filesystem.&lt;/p&gt;

&lt;p&gt;In this guide, we’ll use Docker to quickly deploy Redis using the official image on &lt;a href="https://hub.docker.com/_/redis"&gt;Docker Hub&lt;/a&gt;. Compared to bare metal installation, Docker enables a simpler set up procedure and won’t pollute your host with new packages. Make sure you’ve got a functioning Docker installation on your host before you continue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create a Redis container&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can create an instance of Redis running in a container by pulling the image in the Docker.&lt;/p&gt;

&lt;p&gt;Shown below is the command syntax we’ll use in Docker to create the Redis database container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --name my-redis -p 6379:6379 -d redis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--name&lt;/code&gt; sets the name of our container and though it’s completely optional, it helps you find your container more easily in case you run multiple containers or you want to connect to it&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-p&lt;/code&gt; maps the port 6379 from our machine to the same port in the container, so we can connect to the database from outside the container on that port&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-d&lt;/code&gt; specifies that the container should run in detached mode which you can think of it as running the container in the background.&lt;/p&gt;

&lt;p&gt;We can confirm Redis Docker is running by using &lt;a href="https://docs.docker.com/engine/reference/commandline/ps"&gt;docker ps&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;~$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                       NAMES
d7c0d2191f51   redis     "docker-entrypoint.s…"   3 seconds ago   Up 2 seconds   0.0.0.0:6379-&amp;gt;6379/tcp, :::6379-&amp;gt;6379/tcp   my-redis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Connect to Redis from host&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s see if we can also connect to Redis from my laptop. First, we need &lt;a href="https://redis.io/topics/rediscli"&gt;redis-cli&lt;/a&gt; (Redis command-line interface) installed locally.&lt;/p&gt;

&lt;p&gt;Then, simply do tests again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~$ redis-cli
127.0.0.1:6379&amp;gt; ping
PONG
127.0.0.1:6379&amp;gt; exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I’ll post next parts of this tutorial to show you how to host our code and Redis on &lt;a href="https://www.utopiops.com/?ref=dev.to"&gt;utopiops.com&lt;/a&gt; . With Utopiops you can just push your code and automatically the build, and deployment happens for you. You can host your applications on Utopiops directly or on your own cloud platform and simply manage it by Utopiops.&lt;/p&gt;

</description>
      <category>redis</category>
      <category>docker</category>
      <category>programming</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
