<?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: karenpanahi</title>
    <description>The latest articles on DEV Community by karenpanahi (@karenpanahi).</description>
    <link>https://dev.to/karenpanahi</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%2F697532%2F740e56c7-f7cd-4a99-993d-a7def6b0a26d.png</url>
      <title>DEV Community: karenpanahi</title>
      <link>https://dev.to/karenpanahi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karenpanahi"/>
    <language>en</language>
    <item>
      <title>proxy with wget </title>
      <dc:creator>karenpanahi</dc:creator>
      <pubDate>Fri, 12 Nov 2021 17:09:20 +0000</pubDate>
      <link>https://dev.to/karenpanahi/proxy-with-wget-1nnk</link>
      <guid>https://dev.to/karenpanahi/proxy-with-wget-1nnk</guid>
      <description>&lt;p&gt;&lt;a href="https://askubuntu.com/questions/346649/how-do-i-force-wget-to-use-a-proxy-server-without-modifying-system-files"&gt;https://askubuntu.com/questions/346649/how-do-i-force-wget-to-use-a-proxy-server-without-modifying-system-files&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.thegeekdiary.com/how-to-use-wget-to-download-file-via-proxy/"&gt;https://www.thegeekdiary.com/how-to-use-wget-to-download-file-via-proxy/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  follow:
&lt;/h3&gt;

&lt;p&gt;Without modifying your system files at /etc/wgetrc you could create a file at your home directory ~/.wgetrc. It will enable you to modify wget settings locally at user level. Now write the following at ~/.wgetrc to use wget behind a proxy server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use_proxy = on
http_proxy =  http://username:password@proxy.server.address:port/
https_proxy =  http://username:password@proxy.server.address:port/
ftp_proxy =  http://username:password@proxy.server.address:port/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you do not have proxy username and password just write the proxy-address and port everywhere like,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http_proxy =  http://proxy.server.address:port/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export http_proxy=http://110.232.67.44:55443/
export https_proxy=http://110.232.67.44:55443/
export ftp_proxy=http://110.232.67.44:55443/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for checking the environement variables you can do :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;env | grep proxy 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should work. I am assuming you already have proxy settings for all other applications.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>mysql docker config </title>
      <dc:creator>karenpanahi</dc:creator>
      <pubDate>Sat, 30 Oct 2021 13:22:58 +0000</pubDate>
      <link>https://dev.to/karenpanahi/mysql-docker-config-3l2h</link>
      <guid>https://dev.to/karenpanahi/mysql-docker-config-3l2h</guid>
      <description>&lt;p&gt;&lt;a href="https://phoenixnap.com/kb/mysql-docker-container"&gt;https://phoenixnap.com/kb/mysql-docker-container&lt;/a&gt;&lt;br&gt;
&lt;a href="https://towardsdatascience.com/connect-to-mysql-running-in-docker-container-from-a-local-machine-6d996c574e55"&gt;https://towardsdatascience.com/connect-to-mysql-running-in-docker-container-from-a-local-machine-6d996c574e55&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 apt-get install mysql-client

docker run --name=mysqlDocker --env="MYSQL_ROOT_PASSWORD=yourRootPassword" -d mysql/mysql-server 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now you have to change mysql root user host to accept all ips:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it &amp;lt;containerName&amp;gt; bash
mysql -u root -p 
# enter the password you entered in the container config

# in mysql bash enter:
update mysql.user set host='%' where user='root';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Configure Mysql Container
&lt;/h4&gt;

&lt;p&gt;you have to use a .cnf file or you will have this error :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;create an alternative config file on the host machine and mount them inside the container.&lt;/p&gt;

&lt;p&gt;1.First, create a new directory on the host machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir -p /root/docker/[container_name]/conf.d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Create a custom MySQL config file inside that directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /root/docker/[container_name]/conf.d/myCustom.cnf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Once in the file, you can add lines with the desired configuration.&lt;/p&gt;

&lt;p&gt;For example, if you want to increase the maximum number of connections to 250 (instead of the default 151), add the following lines to the configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[mysqld]
bind-address  = 0.0.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.change the location of the data directory :&lt;br&gt;
    4.1. Find an appropriate volume on the host and create a &lt;br&gt;
        data directory on it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir -p /storage/docker/mysqlData
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.2. Save and exit the file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For the changes to take place, you need to remove and rerun the MySQL container.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run \
--detach \
--name=[container_name] \
--restart unless-stopped
--env="MYSQL_ROOT_PASSWORD=my_password" \
--publish 66030:3306 \
--volume=/root/docker/[container_name]/conf.d:/etc/mysql/conf.d \
--volume=/storage/docker/mysqlData:/var/lib/mysql \
mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now you can use either dockerized phpmyadmin or workbench on your host machines.if you want to use phpmyadmin do the following steps otherwise you can jump to step 7.&lt;/p&gt;

&lt;h4&gt;
  
  
  dockerized phpmyadmin
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume create phpmyadminVolume
phpmyadmin-volume

docker run --name mk-phpmyadmin -v phpmyadminVolume:/etc/phpmyadmin/config.user.inc.php --link mk-mysql:db -p 82:80 -d phpmyadmin/phpmyadmin

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Access MySQL via phpMyAdmin
&lt;/h4&gt;

&lt;p&gt;Open your browser and visit &lt;a href="http://localhost:82"&gt;http://localhost:82&lt;/a&gt; to access phpMyAdmin UI.&lt;/p&gt;

&lt;h4&gt;
  
  
  Mysql workbench
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;leave the host option to localhost, in the port section enter the port you exposed for mysql container(in our case 6603) .user and password are the ones you specified in the above section (in our case root ).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;bonne chance !&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Tree command linux</title>
      <dc:creator>karenpanahi</dc:creator>
      <pubDate>Tue, 26 Oct 2021 10:22:57 +0000</pubDate>
      <link>https://dev.to/karenpanahi/tree-command-linux-2il3</link>
      <guid>https://dev.to/karenpanahi/tree-command-linux-2il3</guid>
      <description>&lt;h3&gt;
  
  
  really simple tut to get you going with tree command
&lt;/h3&gt;

&lt;h4&gt;
  
  
  tag meanings :
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tree -a :all 
tree -f :list wit fullpath prefix
tree -d :directories 
tree -df :dirs with fullpath prefix !
# this is the depth the tree goes in(2 means 2 directories) 
tree -L &amp;lt;desired lenght&amp;gt; &amp;gt;&amp;gt;&amp;gt;tree -L  2 
-u: the username
-g: the groupname 
-p:permissions 
-s :size
-h: for showing the size with K ,M ,T
tree -L 3 -pug

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  wild card
&lt;/h4&gt;

&lt;p&gt;wildcard command would be -P (pattern) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tree -f -P cata* 
$prune the empty dirs:
tree -f --prune 
$print with permissions 
tree -f -p 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Maybe one day ... </title>
      <dc:creator>karenpanahi</dc:creator>
      <pubDate>Sun, 24 Oct 2021 22:53:17 +0000</pubDate>
      <link>https://dev.to/karenpanahi/maybe-one-day--4f5o</link>
      <guid>https://dev.to/karenpanahi/maybe-one-day--4f5o</guid>
      <description>&lt;h2&gt;
  
  
  table of content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt; Nextcloud setup with docker &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Nextcloud setup &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;helpful url:&lt;br&gt;
&lt;a href="https://www.cloudsavvyit.com/12476/how-to-self-host-a-collaborative-cloud-with-nextcloud-and-docker/"&gt;https://www.cloudsavvyit.com/12476/how-to-self-host-a-collaborative-cloud-with-nextcloud-and-docker/&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 run -d -p 8082:80 nextcloud
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;link a 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;--link my-sql:mysql 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then use the mysql as the database host on the setup.&lt;/p&gt;

&lt;p&gt;?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>docker  basics ubuntu </title>
      <dc:creator>karenpanahi</dc:creator>
      <pubDate>Sat, 23 Oct 2021 10:58:07 +0000</pubDate>
      <link>https://dev.to/karenpanahi/docker-basics-ubuntu-2ch5</link>
      <guid>https://dev.to/karenpanahi/docker-basics-ubuntu-2ch5</guid>
      <description>&lt;h2&gt;
  
  
  table of content :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt; Mysql configuration&lt;/li&gt;
&lt;li&gt; Docker Network &lt;/li&gt;
&lt;li&gt; Using ipv6 &lt;/li&gt;
&lt;li&gt; docker compose &lt;/li&gt;
&lt;li&gt; docker data persistence and file management&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Mysql docker conf &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://phoenixnap.com/kb/mysql-docker-container"&gt;https://phoenixnap.com/kb/mysql-docker-container&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;mysql &lt;/p&gt;

&lt;p&gt;&lt;a href="https://docker-curriculum.com/#webapps-with-docker"&gt;https://docker-curriculum.com/#webapps-with-docker&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.tutorialspoint.com/docker/"&gt;https://www.tutorialspoint.com/docker/&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  tut:
&lt;/h1&gt;

&lt;p&gt;benefits  :&lt;br&gt;
no environmental configuration needed on the server Exept &lt;br&gt;
Docker Runtime &lt;br&gt;
if we use the same app but different versions  they will use the same port ,how does that work??&lt;br&gt;
-the containers use the same port but the port that the host binds to them are different for example redis:latest &amp;amp; redis:4.6 both use port 6379 but the ports that host assigned to them are different (i.e 3000 &amp;amp; 3001)&lt;br&gt;
but you have to use the host port for each container :&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;someApp://localhost:3000&lt;br&gt;
someApp://localhost:3001&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;but if you dont specify the ports while runnuig the container ,it would be unreachable for other apps so :&lt;br&gt;
sudo docker run -p:&lt;br&gt;
sudo docker run -p6000:6379&lt;/p&gt;

&lt;p&gt;postgres:version&lt;br&gt;
if not specified&lt;br&gt;
for example: postgres:9.6 &lt;br&gt;
sudo docker -d :detached mode&lt;/p&gt;
&lt;h1&gt;
  
  
  some basic commands
&lt;/h1&gt;

&lt;p&gt;sudo docker logs containerId &lt;br&gt;
if you want to give container a name:&lt;br&gt;
sudo docker docker run -p6000:6379 --name  &lt;br&gt;
docker run --name heshmat redis&lt;/p&gt;

&lt;p&gt;$ lists the processes running within a container.&lt;br&gt;
    docker top container options&lt;/p&gt;

&lt;p&gt;$ Display a live stream of container(s) resource usage statistics. &lt;br&gt;
    docker stats options container &lt;/p&gt;

&lt;p&gt;$ applying limitations:&lt;br&gt;
    docker container run -d --name testContainer &lt;br&gt;
--cpu-shares 512 --memory 128M -p 8080:80 nginx&lt;/p&gt;

&lt;p&gt;$ if you have an existing container you can update it by:&lt;br&gt;
    docker container update --cpu-shares 512 ...&lt;/p&gt;

&lt;p&gt;for debugging:&lt;br&gt;
sudo docker -it containerId /bin/bash&lt;/p&gt;

&lt;p&gt;start &amp;amp;run :&lt;br&gt;
run creates new &lt;br&gt;
start restarts already made container&lt;br&gt;
sudo docker image &lt;br&gt;
sudo docker run &lt;br&gt;
sudo docker pull &lt;br&gt;
sudo docker run -it packageName /bin/bash &lt;br&gt;
in the above command we have:&lt;br&gt;
-it which runs the (centOs) in interactive mode &lt;br&gt;
/bin/bash which runs bash shell once packageName(centOs) is running&lt;/p&gt;

&lt;p&gt;TAG − This is used to logically tag images.&lt;br&gt;
Image ID − This is used to uniquely identify the image.&lt;/p&gt;

&lt;p&gt;sudo docker rmi ImageId  #removing an image &lt;br&gt;
sudo docker images -q #just ids !&lt;br&gt;
sudo docker inspect ImageName # returns bunch of info about the ImageName&lt;/p&gt;

&lt;p&gt;sudo docker run -it busybox sh &lt;br&gt;
interactive mode with&lt;br&gt;&lt;br&gt;
docker container prune #this deletes all stopped containers .&lt;/p&gt;

&lt;p&gt;the ps cmd is abbr of process status and is available inside a container &lt;br&gt;
-f ,--filter  :filter  output based on the condition provided&lt;br&gt;
(here is -f status=exited)&lt;br&gt;
--quiet ,-q :just the id's&lt;br&gt;
--all ,-a :running and stopped containers&lt;br&gt;
sudo docker rm $(sudo docker ps -a -q -f status=exited)&lt;/p&gt;
&lt;h5&gt;
  
  
  the dollar sign pass the output of the other cmd to previous
&lt;/h5&gt;

&lt;p&gt;sudo docker run --rm prakhar1989/static-site &lt;br&gt;
$# the --rm deletes the container after it has been exited&lt;/p&gt;

&lt;p&gt;sudo docker run -d -P --name static-site prakhar1989/static-site &lt;br&gt;
$#-P (capital p) publish all exposed ports to random ports.&lt;br&gt;
$#-D :run the docker on debug mode &lt;br&gt;
$#-&lt;/p&gt;

&lt;p&gt;docker port static-site&lt;br&gt;
output &amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
80/tcp -&amp;gt; 0.0.0.0:32769&lt;br&gt;
443/tcp -&amp;gt; 0.0.0.0:32768&lt;/p&gt;
&lt;h3&gt;
  
  
  containers
&lt;/h3&gt;

&lt;p&gt;sudo docker top containerId &lt;br&gt;
$ this shows the running process &lt;br&gt;
sudo docker stop containerId&lt;br&gt;
docker rm containerId &lt;br&gt;
sudo docker stats containerId&lt;br&gt;
sudo docker kill containerId &lt;br&gt;
sudo docker pause conatainerID &lt;br&gt;
sudo docker unpause containerId  &lt;/p&gt;
&lt;h3&gt;
  
  
  making Dockerfile :
&lt;/h3&gt;

&lt;p&gt;$# specifying the base image &lt;br&gt;
FROM python:3 &lt;/p&gt;

&lt;p&gt;$# set a directory for the app&lt;br&gt;
WORKDIR /usr/src/app&lt;/p&gt;

&lt;p&gt;$# copy all the files to the container&lt;br&gt;
COPY . .&lt;/p&gt;

&lt;p&gt;$# install dependencies&lt;br&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;/p&gt;

&lt;p&gt;the next thing wew need to specify is the port number that needs to be exposed.since flaskis runnig on port 5000 thats what we will indicate .&lt;/p&gt;

&lt;p&gt;EXPOSE 5000&lt;/p&gt;

&lt;p&gt;then we write the command for running the application :&lt;br&gt;
CMD ["python","./app.py"]&lt;/p&gt;
&lt;h1&gt;
  
  
  building the image:
&lt;/h1&gt;

&lt;p&gt;docker build -t / .&lt;br&gt;
(the period at last is important )&lt;/p&gt;
&lt;h3&gt;
  
  
  Docker network  &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;h4&gt;
  
  
  user-defined network:
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create &amp;lt;networkName&amp;gt;
docker network rm &amp;lt;networkName&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;disconnect the containers to the network you want &lt;br&gt;
to remove&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  connect a container to a user-defined network
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; docker create --name my-nginx \
  --network my-net \
  --publish 8080:80 \
  nginx:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;to connect a running container to userdef network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network connect &amp;lt;networkName&amp;gt; &amp;lt;containerName&amp;gt;
docker network connect my-net my-container 
docker network disconnect myNet myContainer 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the above command  connect/disconnect an  already existing container to an already existing network  &lt;/p&gt;

&lt;p&gt;\&lt;/p&gt;

&lt;h3&gt;
  
  
  Using ipv6 &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;you have to enable the option on the docker daemon and reload its configuration before assigning any kind of network to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  enable forwarding from docCont to  the outside world
&lt;/h2&gt;

&lt;p&gt;By default, traffic from containers connected to the default bridge network is not forwarded to the outside world. To enable forwarding, you need to change two settings. These are not Docker commands and they affect the Docker host’s kernel.&lt;/p&gt;

&lt;p&gt;1.configure linux kernel to allow IP forwarding&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sysctl net.ipv4.conf.all.forwarding=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;change policy for iptables FORWARD form DROP to ACCEPT
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo iptables -P FORWARD ACCEPT 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  ATTENTION: these settings do not persist across a reboot so ,you may need to add them to a start-up script .
&lt;/h4&gt;

&lt;h2&gt;
  
  
  overlay networks
&lt;/h2&gt;

&lt;p&gt;The overlay network driver creates a distributed network among multiple Docker daemon hosts&lt;/p&gt;

&lt;p&gt;Start the registry automatically&lt;br&gt;
If you want to use the registry as part of your permanent infrastructure, you should set it to restart automatically when Docker restarts or if it exits. This example uses the --restart always flag to set a restart policy for the registry.&lt;br&gt;
$ &lt;/p&gt;

&lt;p&gt;Tag the image as localhost:5000/my-ubuntu. This creates an additional tag for the existing image. When the first part of the tag is a hostname and port, Docker interprets this as the location of a registry, when pushing.&lt;/p&gt;
&lt;h1&gt;
  
  
  DATA manging in docker
&lt;/h1&gt;

&lt;p&gt;1-use Data Volumes &lt;br&gt;
    docker volume --help&lt;br&gt;
2-Mount host directory (bind mounts)&lt;/p&gt;

&lt;p&gt;-the bind mount or volume writes the data to the host filesystem as tmpfs mount write the data into host memory .&lt;br&gt;
-Volumes are stored in a part of the host filesystem which is managed by Docker (/var/lib/docker/volumes/ on Linux). Non-Docker processes should not modify this part of the filesystem. Volumes are the best way to persist data in Docker.&lt;br&gt;
-Bind mounts may be stored anywhere on the host system. They may even be important system files or directories. Non-Docker processes on the Docker host or a Docker container can modify them at any time.&lt;/p&gt;
&lt;h1&gt;
  
  
  Use data Volume :
&lt;/h1&gt;

&lt;p&gt;create a data volume:&lt;br&gt;
    docker volume create my-vol&lt;br&gt;
view all data volumes:&lt;br&gt;
    docker volume ls &lt;br&gt;
inspect a data volume :&lt;br&gt;
    docker volume inspect my-vol&lt;/p&gt;

&lt;p&gt;--mount&lt;br&gt;
   docker run -d \&lt;br&gt;
    --name=nginxtest \&lt;br&gt;
    --mount source=nginx- &lt;br&gt;
    vol,destination=/usr/share/nginx/html \&lt;br&gt;
    nginx:latest&lt;/p&gt;

&lt;p&gt;volumes arent controled by docker meaning that if you delete a container the volume is  still there. for deletion :&lt;br&gt;
    docker volume rm my-vol&lt;/p&gt;

&lt;p&gt;unknown or tangling volumes are a mess .get rid of them by:&lt;br&gt;
    docker volume prune&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run -d -P \
--name web \
# -v /src/webapp:/opt/webapp \
  --mount type=bind, source=/src/webapp,target=/opt/webapp
training/webapp \




    python app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The above command to load the host /src/webapp directory into a container /opt/webapp directory.  --mount parameter throws an error if the local directory does not exist.&lt;br&gt;
--mount also can mount a single data volume.&lt;br&gt;
You can also set readonly volume as --mount source=nginx-vol,destination=/usr/share/nginx/html,readonly.&lt;/p&gt;
&lt;h1&gt;
  
  
  Docker network configuration
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://jstobigdata.com/docker-network-configuration/"&gt;https://jstobigdata.com/docker-network-configuration/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-p is used to specify hostPort:containerPor .&lt;br&gt;
-P Is used to map any port which is between 49000 to 49900 into the container open network port.&lt;/p&gt;

&lt;p&gt;for seeing the port :&lt;br&gt;
    sudo docker port containerName&lt;/p&gt;

&lt;p&gt;use this format for port specification:&lt;br&gt;
    docker run -d -p &lt;a&gt;hostPort:theContainerPort&lt;/a&gt;&lt;br&gt;
you can use this to run the command:&lt;br&gt;
    curl localhost:&lt;br&gt;
    curl localhost: 5000&lt;br&gt;
random:&lt;br&gt;
    docker run -d -p 80.674.839.82:5000:5000&lt;br&gt;
you can specify it to use udp ,but the default is tcp:&lt;br&gt;
    docker run -dp localhost:port:port/udp container ....&lt;/p&gt;

&lt;p&gt;Docker network configuration – docker allows network services for externally accessing containers and container interconnections. There are also open source network management tools for docker. Make sure you have a good understanding of the ecosystem before reading this article, check out the introduction.&lt;/p&gt;

&lt;p&gt;Will be using docker network to establish a connection, I do not recommend using --link (if you are already using it, please stop).&lt;/p&gt;

&lt;p&gt;Copy&lt;br&gt;
1&lt;br&gt;
docker network create -d bridge my-bridge-nwk&lt;br&gt;
-d – Parameter is used to specify the docker network types, as explained above, bridge, overlay, macvlan and etc.&lt;/p&gt;

&lt;p&gt;Container connection&lt;br&gt;
Run 2 containers and connect them using the new bridge my-bridge-nwk.&lt;/p&gt;

&lt;p&gt;Copy&lt;br&gt;
docker run -it --rm --name busybox1 --network my-bridge-nwk busybox sh&lt;br&gt;
1&lt;br&gt;
docker run -it --rm --name busybox1 --network my-bridge-nwk busybox sh&lt;br&gt;
Open  another terminal and run the below code,&lt;/p&gt;

&lt;p&gt;Copy&lt;br&gt;
docker run -it --rm --name busybox2 --network my-bridge-nwk busybox sh&lt;br&gt;
docker run -it --rm --name busybox2 --network my-bridge-nwk busybox sh&lt;br&gt;
1&lt;br&gt;
docker run -it --rm --name busybox2 --network my-bridge-nwk busybox sh&lt;br&gt;
If both the above code was sucessful, try pinging one container from another, like ping busybox2 from busybox1.&lt;/p&gt;

&lt;p&gt;/ # ping busybox2&lt;/p&gt;

&lt;p&gt;NOTE: For multi containers that need to connect to each other,Docker-Compose is recommanded.&lt;/p&gt;
&lt;h1&gt;
  
  
  Edit network configuration file
&lt;/h1&gt;

&lt;p&gt;Docker 1.2.0 onwards, it is possible to edit the container’s /etc/hosts, /etc/hostnameand and /etc/resolv.conffiles.&lt;/p&gt;
&lt;h3&gt;
  
  
  Docker Compose &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;helpful url:&lt;br&gt;
&lt;a href="https://docs.linuxserver.io/general/docker-compose"&gt;https://docs.linuxserver.io/general/docker-compose&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  sample docker-compose.yml file :
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "2.1"
services:
  heimdall:
    image: linuxserver/heimdall
    container_name: heimdall
    volumes:
      - /home/user/appdata/heimdall:/config
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
    ports:
      - 80:80
      - 443:443
    restart: unless-stopped
  nginx:
    image: linuxserver/nginx
    container_name: nginx
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
    volumes:
      - /home/user/appdata/nginx:/config
    ports:
      - 81:80
      - 444:443
    restart: unless-stopped
  mariadb:
    image: linuxserver/mariadb
    container_name: mariadb
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=ROOT_ACCESS_PASSWORD
      - TZ=Europe/London
    volumes:
      - /home/user/appdata/mariadb:/config
    ports:
      - 3306:3306
    restart: unless-stopped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;you can simply run :&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 up -d 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;from within the same folder and the heimdall image will be automatically pulled, and a container will be created and started.&lt;/p&gt;

&lt;h2&gt;
  
  
  docker-compose example
&lt;/h2&gt;

&lt;p&gt;helpful url: &lt;br&gt;
&lt;a href="https://docs.docker.com/compose/gettingstarted/"&gt;https://docs.docker.com/compose/gettingstarted/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1-create a directory &lt;br&gt;
2-create an app.py in the dir with this context :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;time&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;redis&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Redis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'redis'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;6379&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_hit_count&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;retries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;incr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'hits'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exceptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;ConnectionError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;retries&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt;
            &lt;span class="n"&gt;retries&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_hit_count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;'Hello World! I have been seen {} times.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3-create a file requirements.txt in your project directory and paste this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flask
redis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Docker data persistence and file management &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;h2&gt;
  
  
  docker volumes
&lt;/h2&gt;

&lt;p&gt;docker volumes are handled by docker and therefore independent of both directory structure and OS of the host machine.when we use volume , a new directory is created within docker's storage dir on the host machine. and docker manages that directory's contents.&lt;/p&gt;

&lt;h5&gt;
  
  
  Use cases
&lt;/h5&gt;

&lt;p&gt;if you want your data to be fully managed by docker and accessed only through docker containers, volumes are the right choice.&lt;/p&gt;

&lt;p&gt;if you need full control of the storage and plan on allowing other processes besides Docker to access or modify the storage layer ,bind mounts could be the right choice but you have to consider the security risks explained here.&lt;/p&gt;

&lt;h5&gt;
  
  
  Getting started using volumes
&lt;/h5&gt;

&lt;p&gt;the docker daemon store data within the docker directory &lt;br&gt;
/var/lib/docker/volumes/...&lt;br&gt;
Let’s say you want to create a PostgreSQL container, and you are interested in persisting the data. Start with a folder called postgres in :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$HOME/docker/volumes/postgres

docker run --rm --name postgres-db -e POSTGRES_PASSWORD=password --mount type=volume,source=$HOME/docker/volumes/postgres,target=/var/lib/postgresql/data -p 2000:5432 -d postgres

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternately, here is the same command using the shorthand flag -v:&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 --rm --name postgres-db -e POSTGRES_PASSWORD=password --v $HOME/docker/volumes/postgres:/var/lib/postgresql/data -p 2000:5432 -d postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Get dokuwiki running with docker ubuntu20.04</title>
      <dc:creator>karenpanahi</dc:creator>
      <pubDate>Thu, 21 Oct 2021 09:16:08 +0000</pubDate>
      <link>https://dev.to/karenpanahi/get-dokuwiki-running-with-docker-ubuntu2004-39c2</link>
      <guid>https://dev.to/karenpanahi/get-dokuwiki-running-with-docker-ubuntu2004-39c2</guid>
      <description>&lt;h2&gt;
  
  
  create a docker volume :
&lt;/h2&gt;

&lt;p&gt;for data persistency container needs one volume on the docker host ,which will be mapped to /config folder within the  container. create the volume by :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    docker volume create dokuwiki 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  creating the container
&lt;/h1&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker create \
--name=dokuwiki \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=America/New_York \
-e APP_URL=[YOURURL] `#optional` \
-p 8081:80 \
-v dokuwiki:/config \
--restart unless-stopped \
linuxserver/dokuwiki
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  variable explenation:
&lt;/h1&gt;

&lt;p&gt;-e PUID : set process userid to 1000 to help avoid permission issues &lt;/p&gt;

&lt;p&gt;-e PGID : Sets Process Group ID to 1000 to help avoid permission issues.&lt;/p&gt;

&lt;p&gt;-e TZ   : time zone (with this format: America/Newyork)&lt;/p&gt;

&lt;p&gt;run the 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 start &amp;lt;containerId&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you followed the above configuration then you're done go to &lt;a href="http://localhost:8081/install.php"&gt;http://localhost:8081/install.php&lt;/a&gt; for admin config &lt;/p&gt;

&lt;p&gt;but if you want to update the already running 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 update --restart unless-stopped container_id
    # verify the changes you made : 
    docker inspect container_id

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and search for RestartPolicy ,this is what you will be searching for :&lt;br&gt;
        "RestartPolicy": {&lt;br&gt;
        "Name": "unless-stopped",&lt;/p&gt;

&lt;p&gt;you are done !&lt;br&gt;
go to this URL :&lt;a href="http://SERVER-IP:8081/install.php"&gt;http://SERVER-IP:8081/install.php&lt;/a&gt; for admin configuration .&lt;/p&gt;

&lt;p&gt;this might also be helpful:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codeopolis.com/posts/how-to-install-dokuwiki-on-docker/"&gt;https://codeopolis.com/posts/how-to-install-dokuwiki-on-docker/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
