<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Docker on Alperen Doc</title><link>https://blog.ulutasalperen.com/docs/docker/</link><description>Recent content in Docker on Alperen Doc</description><generator>Hugo</generator><language>en</language><atom:link href="https://blog.ulutasalperen.com/docs/docker/index.xml" rel="self" type="application/rss+xml"/><item><title>docker-kurulum-hardening-debian</title><link>https://blog.ulutasalperen.com/docs/docker/docker-kurulum-hardening-debian/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-kurulum-hardening-debian/</guid><description>&lt;h3 id="debian-13-için-güvenli-docker-ve-docker-compose-kurulum-dokümantasyonu"&gt;Debian 13 İçin Güvenli Docker ve Docker Compose Kurulum Dokümantasyonu&lt;a class="anchor" href="#debian-13-i%c3%a7in-g%c3%bcvenli-docker-ve-docker-compose-kurulum-dok%c3%bcmantasyonu"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;h4 id="1-sistem-hazırlığı-ve-bağımlılıklar"&gt;1. Sistem Hazırlığı ve Bağımlılıklar&lt;a class="anchor" href="#1-sistem-haz%c4%b1rl%c4%b1%c4%9f%c4%b1-ve-ba%c4%9f%c4%b1ml%c4%b1l%c4%b1klar"&gt;#&lt;/a&gt;&lt;/h4&gt;&#10;&lt;p&gt;Kuruluma başlamadan önce sistemin güncel olduğundan ve paketleri HTTPS üzerinden alabilmek için gerekli araçların yüklendiğinden emin oluyoruz.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update &lt;span style="color:#f92672"&gt;&amp;amp;&amp;amp;&lt;/span&gt; sudo apt upgrade -y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install -y ca-certificates curl gnupg&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="2-resmi-docker-deposu-ve-gpg-anahtarının-eklenmesi"&gt;2. Resmi Docker Deposu ve GPG Anahtarının Eklenmesi&lt;a class="anchor" href="#2-resmi-docker-deposu-ve-gpg-anahtar%c4%b1n%c4%b1n-eklenmesi"&gt;#&lt;/a&gt;&lt;/h4&gt;&#10;&lt;p&gt;Paketlerin bütünlüğünü doğrulamak için Docker&amp;rsquo;ın resmi GPG anahtarını eklemek güvenlik açısından zorunludur.&lt;/p&gt;&#10;&lt;p&gt;GPG anahtarını indirip yapılandırıyoruz:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo install -m &lt;span style="color:#ae81ff"&gt;0755&lt;/span&gt; -d /etc/apt/keyrings&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo rm -f /etc/apt/keyrings/docker.gpg&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod a+r /etc/apt/keyrings/docker.gpg&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;&lt;code&gt;rm -f&lt;/code&gt; satırını ekledik çünkü anahtar daha önce indirilmişse &lt;code&gt;gpg --dearmor -o&lt;/code&gt; komutu &amp;ldquo;File exists&amp;rdquo; hatası verir. Bu sayede komut güvenle tekrar çalıştırılabilir.&lt;/p&gt;</description></item><item><title>manage-docker-as-non-root-user</title><link>https://blog.ulutasalperen.com/docs/docker/manage-docker-as-non-root-user/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/manage-docker-as-non-root-user/</guid><description>&lt;h2 id="manage-docker-as-a-non-root-user"&gt;&lt;a href="https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user"&gt;Manage Docker as a non-root user&lt;/a&gt;&lt;a class="anchor" href="#manage-docker-as-a-non-root-user"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The Docker daemon binds to a Unix socket, not a TCP port. By default it&amp;rsquo;s the &lt;code&gt;root&lt;/code&gt; user that owns the Unix socket, and other users can only access it using &lt;code&gt;sudo&lt;/code&gt;. The Docker daemon always runs as the &lt;code&gt;root&lt;/code&gt; user.&lt;/p&gt;&#10;&lt;p&gt;If you don&amp;rsquo;t want to preface the &lt;code&gt;docker&lt;/code&gt; command with &lt;code&gt;sudo&lt;/code&gt;, create a Unix group called &lt;code&gt;docker&lt;/code&gt; and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the &lt;code&gt;docker&lt;/code&gt; group. On some Linux distributions, the system automatically creates this group when installing Docker Engine using a package manager. In that case, there is no need for you to manually create the group.&lt;/p&gt;</description></item><item><title>docker-containers-images</title><link>https://blog.ulutasalperen.com/docs/docker/docker-containers-images/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-containers-images/</guid><description>&lt;h1 id="containers"&gt;Containers&lt;a class="anchor" href="#containers"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.&lt;/p&gt;&#10;&lt;p&gt;&amp;ndash; &lt;a href="https://www.docker.com/resources/what-container/"&gt;Docker&lt;/a&gt;&lt;/p&gt;&#10;&lt;/blockquote&gt;&lt;p&gt;Containers, on the other hand, gives us 90% of the benefits of virtual machines, but are &lt;em&gt;super&lt;/em&gt; lightweight. &lt;em&gt;Containers boot up in seconds, while virtual machines can take minutes.&lt;/em&gt;&lt;/p&gt;&#10;&lt;h2 id="virtual-machine-architecture"&gt;Virtual Machine Architecture&lt;a class="anchor" href="#virtual-machine-architecture"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;img src="https://storage.googleapis.com/qvault-webapp-dynamic-assets/course_assets/QS4HGNG.png" alt="" /&gt;&lt;/p&gt;&#10;&lt;h2 id="container-docker-architectures"&gt;Container (Docker) Architectures&lt;a class="anchor" href="#container-docker-architectures"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;img src="https://storage.googleapis.com/qvault-webapp-dynamic-assets/course_assets/fmZG1Zd-662x400.png" alt="" /&gt;&lt;/p&gt;</description></item><item><title>docker-volumes</title><link>https://blog.ulutasalperen.com/docs/docker/docker-volumes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-volumes/</guid><description>&lt;h1 id="volumes"&gt;Volumes&lt;a class="anchor" href="#volumes"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;By default, Docker containers don&amp;rsquo;t retain any state from &lt;em&gt;past&lt;/em&gt; containers. For example, if I:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Start a container from an image&lt;/li&gt;&#10;&lt;li&gt;Make some changes to the filesystem (like installing a new package) in that container&lt;/li&gt;&#10;&lt;li&gt;Stop the container&lt;/li&gt;&#10;&lt;li&gt;Start a new container from the same image&lt;/li&gt;&#10;&lt;li&gt;The new container does &lt;em&gt;not&lt;/em&gt; have the changes I made in step 2.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;However, if I restart the &lt;em&gt;stopped&lt;/em&gt; container, it &lt;em&gt;will&lt;/em&gt; have the changes I made. This is only worth mentioning because sometimes developers think that killing an old container and starting a new one is the same as &lt;em&gt;restarting a process&lt;/em&gt; - but that&amp;rsquo;s not true&amp;hellip; it&amp;rsquo;s more like resetting the state of the &lt;em&gt;entire machine&lt;/em&gt; to the original image.&lt;/p&gt;</description></item><item><title>docker-build</title><link>https://blog.ulutasalperen.com/docs/docker/docker-build/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-build/</guid><description>&lt;h1 id="dockerfiles"&gt;Dockerfiles&lt;a class="anchor" href="#dockerfiles"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Docker isn&amp;rsquo;t &lt;em&gt;only&lt;/em&gt; useful for running &lt;em&gt;other&lt;/em&gt; people&amp;rsquo;s software (as we&amp;rsquo;ve been doing so far). It&amp;rsquo;s also a great way to build and package our own software.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://blog.ulutasalperen.com/images/docker/container-image-composition.png" alt="Container image composition" /&gt;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ve used Docker both ways. As a DevOps/platform engineer I&amp;rsquo;m usually using other&amp;rsquo;s images, but as a backend developer I was usually building images for our own servers.&lt;/p&gt;&#10;&lt;p&gt;Docker images are built from &lt;em&gt;Dockerfiles&lt;/em&gt;. A Dockerfile is just a text file that contains all the commands needed to assemble an image. It&amp;rsquo;s essentially the &lt;a href="https://en.wikipedia.org/wiki/Infrastructure_as_Code"&gt;&amp;ldquo;Infrastructure as Code&amp;rdquo;&lt;/a&gt; (IaC) for an image. It runs commands from top to bottom, kind of like a shell script.&lt;/p&gt;</description></item><item><title>optimize-container-images-with-multi-stage-builds</title><link>https://blog.ulutasalperen.com/docs/docker/optimize-container-images-with-multi-stage-builds/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/optimize-container-images-with-multi-stage-builds/</guid><description>&lt;h2 id="the-problem-with-single-stage-builds"&gt;The problem with single-stage builds&lt;a class="anchor" href="#the-problem-with-single-stage-builds"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;When you use the &lt;code&gt;golang&lt;/code&gt; image to compile &lt;em&gt;and&lt;/em&gt; run a Go application in the same stage, the final image inherits the entire Go compiler toolchain - over 800MB of packages and hundreds of CVEs that you don&amp;rsquo;t need at runtime.&lt;/p&gt;&#10;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Single-stage Go builds keep the full compiler toolchain (~800MB+) in the final image even though only the compiled binary is needed at runtime.&lt;/p&gt;</description></item><item><title>docker-network</title><link>https://blog.ulutasalperen.com/docs/docker/docker-network/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-network/</guid><description>&lt;h1 id="docker-network"&gt;Docker-Network&lt;a class="anchor" href="#docker-network"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;h2 id="offline"&gt;Offline&lt;a class="anchor" href="#offline"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Now, let&amp;rsquo;s force a container into &lt;em&gt;offline&lt;/em&gt; mode!&lt;/p&gt;&#10;&lt;p&gt;You might be thinking, &amp;ldquo;why would I want to turn off networking?!?&amp;rdquo; Well, usually it&amp;rsquo;s for security reasons. You might want to remove the network connection from a container in one of these scenarios:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;You&amp;rsquo;re running 3rd party code that you don&amp;rsquo;t trust, and it shouldn&amp;rsquo;t need network access&lt;/li&gt;&#10;&lt;li&gt;You&amp;rsquo;re building an e-learning site, and you&amp;rsquo;re allowing students to execute code on your machines&lt;/li&gt;&#10;&lt;li&gt;You know a container has a virus that&amp;rsquo;s sending malicious requests over the internet, and you want to do an audit&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="network-none"&gt;Network None&lt;a class="anchor" href="#network-none"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;code&gt;docker run&lt;/code&gt; command has a &lt;code&gt;--network none&lt;/code&gt; flag that makes it so that the container can&amp;rsquo;t network with the outside world, which is super useful for isolating containers.&lt;/p&gt;</description></item><item><title>docker-exec-shell</title><link>https://blog.ulutasalperen.com/docs/docker/docker-exec-shell/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-exec-shell/</guid><description>&lt;h1 id="exec"&gt;Exec&lt;a class="anchor" href="#exec"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;When it comes to &lt;em&gt;deploying&lt;/em&gt; applications with Docker, you&amp;rsquo;ll usually just let the container do its thing. For example, the Ghost container we ran in the last chapter started up its own web server (based on the image configuration). We didn&amp;rsquo;t need to run any manual commands in addition to just starting the container.&lt;/p&gt;&#10;&lt;p&gt;That said, it &lt;em&gt;is&lt;/em&gt; possible to run commands inside a running container! It&amp;rsquo;s kinda like the container version of &lt;a href="https://www.ssh.com/ssh/"&gt;ssh&lt;/a&gt;ing into a remote server and running a command.&lt;/p&gt;</description></item><item><title>docker-logs</title><link>https://blog.ulutasalperen.com/docs/docker/docker-logs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-logs/</guid><description>&lt;h1 id="docker-logs"&gt;Docker Logs&lt;a class="anchor" href="#docker-logs"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;When containers are running in detached mode with the &lt;code&gt;-d&lt;/code&gt; flag, you don&amp;rsquo;t see any output in your terminal, which is nice for keeping your terminal clean, but what if something goes &lt;em&gt;wrong&lt;/em&gt;?&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;Enter the &lt;code&gt;docker logs&lt;/code&gt; command&lt;/em&gt;.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker logs &lt;span style="color:#f92672"&gt;[&lt;/span&gt;OPTIONS&lt;span style="color:#f92672"&gt;]&lt;/span&gt; CONTAINER&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="ornek-log"&gt;Ornek log&lt;a class="anchor" href="#ornek-log"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Let&amp;rsquo;s run the Linux &lt;code&gt;alpine&lt;/code&gt; image in a new container in detached mode, and give it a simple command to run to generate some standard output:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -d --name logdate alpine sh -c &lt;span style="color:#e6db74"&gt;&amp;#39;while true; do echo &amp;#34;LOGGING: $(date)&amp;#34;; sleep 1; done&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;sh -c 'while true; do echo &amp;quot;LOGGING: $(date)&amp;quot;; sleep 1; done'&lt;/code&gt; part is just a simple shell script to execute inside the container that prints the current date and time every second.&lt;/p&gt;</description></item><item><title>docker-compose-basic</title><link>https://blog.ulutasalperen.com/docs/docker/docker-compose-basic/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-compose-basic/</guid><description>&lt;p&gt;docker compose ne isimize yariyor dersek, birden fazla konteyneri tek bir yaml dosyasindan yonetmemize yariyor, tek tek docker run ile ugrasmiyoruz ve ayni zamanda restart sayesinde sistem acilinca uygulamayi otomatik ayakta tutabiliyoruz&lt;/p&gt;&#10;&lt;h3 id="temel-calisma-mantigi"&gt;temel calisma mantigi&lt;a class="anchor" href="#temel-calisma-mantigi"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;p&gt;proje klasorunde docker-compose.yml diye bir dosya aciyoruz, icine servisleri, networkleri ve volumeleri yazip sonra compose bunlari otomatik kurup birbirine bagliyor ve dayyum! uygulamalar ayakta oluyor, istegimize gore state&amp;rsquo;ini ayarlayabiliyoruz&lt;/p&gt;&#10;&lt;h3 id="ornek-1---tier1-docker-composeyml"&gt;ornek 1 - tier1 (docker-compose.yml)&lt;a class="anchor" href="#ornek-1---tier1-docker-composeyml"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;p&gt;asagidaki ornekte bir nginx web sunucusu ve bir postgres veritabani var, en cok kullandigimiz temel seyler icinde.&lt;/p&gt;</description></item><item><title>var-olan-volume-uzerine-docker-compose</title><link>https://blog.ulutasalperen.com/docs/docker/var-olan-volume-uzerine-docker-compose/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/var-olan-volume-uzerine-docker-compose/</guid><description>&lt;h1 id="ilk-olarak-ben-örnek-olarak-vereceğim"&gt;İlk olarak ben örnek olarak vereceğim&lt;a class="anchor" href="#ilk-olarak-ben-%c3%b6rnek-olarak-verece%c4%9fim"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;h2 id="kullanmak-istediğim-uygulama-filebrowser-kurulum-yaparken-admin-kullanıcının-yanında-rastgele-encrypted-şifre-oluşturuyor-arka-planda-calisirken-ve-docker-logs-da-baktigimdada-parolayi-goruntuleyemedigimden-boyle-bir-yol-izledim"&gt;kullanmak istediğim uygulama (filebrowser) kurulum yaparken admin kullanıcının yanında rastgele encrypted şifre oluşturuyor arka planda calisirken ve &lt;code&gt;docker logs&lt;/code&gt; da baktigimdada parolayi goruntuleyemedigimden boyle bir yol izledim&lt;a class="anchor" href="#kullanmak-istedi%c4%9fim-uygulama-filebrowser-kurulum-yaparken-admin-kullan%c4%b1c%c4%b1n%c4%b1n-yan%c4%b1nda-rastgele-encrypted-%c5%9fifre-olu%c5%9fturuyor-arka-planda-calisirken-ve-docker-logs-da-baktigimdada-parolayi-goruntuleyemedigimden-boyle-bir-yol-izledim"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker compose up -d &lt;span style="color:#75715e"&gt;# -d flag arka planda çalıştır demek&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;böyle yaptığımdan arka planda çalıştigindan parolayi olusturdu ama cikti olarak vermedi onuda olusturdugu persistent volume yazdi ama ben görmedim&lt;/p&gt;&#10;&lt;/blockquote&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker compose up&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;bana şifreyi verecekti ama çoktan iş işten geçti :D şifreyi de hash&amp;rsquo;li olarak sakladığından dosyalara girsem bile fayda vermeyecekti&lt;/p&gt;</description></item><item><title>docker-publish</title><link>https://blog.ulutasalperen.com/docs/docker/docker-publish/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-publish/</guid><description>&lt;h1 id="publishing-to-docker-hub"&gt;Publishing to Docker Hub&lt;a class="anchor" href="#publishing-to-docker-hub"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Let&amp;rsquo;s publish the Go server we Dockerized up to Docker Hub.&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Rebuild the Go binary:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;GOOS&lt;span style="color:#f92672"&gt;=&lt;/span&gt;linux GOARCH&lt;span style="color:#f92672"&gt;=&lt;/span&gt;amd64 go build&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;Rebuild the image. You&amp;rsquo;ll need to use a name that corresponds to &lt;em&gt;your&lt;/em&gt; namespace on Docker Hub. Swap out &lt;code&gt;USERNAME&lt;/code&gt; for &lt;em&gt;your&lt;/em&gt; Docker Hub username.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker build . -t USERNAME/goserver&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;&#10;&lt;li&gt;Run your image in a container to make sure it still works:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -p 8991:8991 USERNAME/goserver&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="4"&gt;&#10;&lt;li&gt;Push the image to Docker Hub:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker push USERNAME/goserver&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id="delete-and-pull"&gt;Delete and Pull&lt;a class="anchor" href="#delete-and-pull"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Let&amp;rsquo;s delete our local copy of the image, then pull it back down from Docker Hub. Just like with GitHub, the nice thing about having images in the cloud is that if something happens to your computer, or you&amp;rsquo;re working on another machine, you can always pull down your images.&lt;/p&gt;</description></item><item><title>docker-kurulum-hardening-rocky</title><link>https://blog.ulutasalperen.com/docs/docker/docker-kurulum-hardening-rocky/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-kurulum-hardening-rocky/</guid><description>&lt;h3 id="rocky-linux-için-güvenli-docker-ve-docker-compose-kurulum-dokümantasyonu"&gt;Rocky Linux İçin Güvenli Docker ve Docker Compose Kurulum Dokümantasyonu&lt;a class="anchor" href="#rocky-linux-i%c3%a7in-g%c3%bcvenli-docker-ve-docker-compose-kurulum-dok%c3%bcmantasyonu"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;h4 id="1-sistem-hazırlığı-ve-bağımlılıklar"&gt;1. Sistem Hazırlığı ve Bağımlılıklar&lt;a class="anchor" href="#1-sistem-haz%c4%b1rl%c4%b1%c4%9f%c4%b1-ve-ba%c4%9f%c4%b1ml%c4%b1l%c4%b1klar"&gt;#&lt;/a&gt;&lt;/h4&gt;&#10;&lt;p&gt;Kuruluma başlamadan önce sistemin güncel olduğundan ve Docker deposunu yönetmemizi sağlayacak araçların yüklendiğinden emin oluyoruz.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo dnf update -y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo dnf install -y dnf-plugins-core&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="2-resmi-docker-deposunun-eklenmesi"&gt;2. Resmi Docker Deposunun Eklenmesi&lt;a class="anchor" href="#2-resmi-docker-deposunun-eklenmesi"&gt;#&lt;/a&gt;&lt;/h4&gt;&#10;&lt;p&gt;Docker, Rocky için ayrı bir depo yayınlamıyor; RHEL türevleri için tek bir depo tutuyor ve bu depo &lt;strong&gt;CentOS&lt;/strong&gt; olarak adlandırılıyor. Rocky&amp;rsquo;de de bu depoyu kullanıyoruz:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;Rocky 10&amp;rsquo;da paket yöneticisi dnf5&amp;rsquo;e geçti; orada komut biraz farklı: &lt;code&gt;sudo dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/centos/docker-ce.repo&lt;/code&gt;. Rocky 9&amp;rsquo;da (dnf4) yukarıdaki komut olduğu gibi çalışır.&lt;/p&gt;</description></item><item><title>docker-distroless-container-images</title><link>https://blog.ulutasalperen.com/docs/docker/docker-distroless-container-images/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/docker/docker-distroless-container-images/</guid><description>&lt;h3 id="distroless-container-imageleri-içlerinde-ne-var-neden-kullanılır"&gt;Distroless Container Image&amp;rsquo;leri: İçlerinde Ne Var, Neden Kullanılır?&lt;a class="anchor" href="#distroless-container-imageleri-i%c3%a7lerinde-ne-var-neden-kullan%c4%b1l%c4%b1r"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;h4 id="1-distroless-nedir-neden-var"&gt;1. Distroless Nedir, Neden Var?&lt;a class="anchor" href="#1-distroless-nedir-neden-var"&gt;#&lt;/a&gt;&lt;/h4&gt;&#10;&lt;p&gt;&lt;code&gt;debian&lt;/code&gt;, &lt;code&gt;ubuntu&lt;/code&gt; veya türevlerinden (&lt;code&gt;node:lts&lt;/code&gt;, &lt;code&gt;python:3&lt;/code&gt; gibi) &lt;code&gt;FROM&lt;/code&gt; ile başlayan container image&amp;rsquo;leri, genellikle dolu dolu bir Linux dağıtımıyla birlikte gelir. Gündelik işler için harikadır ama çoğu container uygulaması çalışma zamanında bu araçların ve kütüphanelerin neredeyse hiçbirine ihtiyaç duymaz. Sonuç? Teknik bir gerekçe olmaksızın daha büyük image boyutu ve yönetmesi gereken daha fazla güvenlik açığı (CVE).&lt;/p&gt;&#10;&lt;p&gt;Küçük, güvenli image&amp;rsquo;ler üretme isteği gayet doğal. Bunun en ekstrem yolu &lt;code&gt;FROM scratch&lt;/code&gt; ile başlamaktır; yani boş bir base image&amp;rsquo;e sadece uygulamamızın gerçekten ihtiyaç duyduğu dosyaları eklemek. Ancak &lt;code&gt;FROM scratch&lt;/code&gt; ile başlayan container&amp;rsquo;lar varsayılan olarak şunları içermez:&lt;/p&gt;</description></item></channel></rss>