Skip to content

Instantly share code, notes, and snippets.

@morteza-mori
Last active May 30, 2020 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morteza-mori/db69962a5559d129e97babf7edaa8016 to your computer and use it in GitHub Desktop.
Save morteza-mori/db69962a5559d129e97babf7edaa8016 to your computer and use it in GitHub Desktop.
docker&tor&proxy setting
apt-get install docker
#show conteiner
docker pull ubuntu
docker ps -a
docker attach c1988b7b20c6
docker start c1988b7b20c6
https://mondedie.fr/viewtopic.php?pid=29034#p29034
https://training.docker.com/self-paced-training
DOCKER VS VAGRANT: http://stackoverflow.com/questions/16647069/should-i-use-vagrant-or-docker-for-creating-an-isolated-environment?rq=1
https://docs.docker.com/kitematic/nginx-web-server/
https://www.digitalocean.com/community/tutorials/docker-explained-how-to-containerize-and-use-nginx-as-a-proxy
###############################
tor privoxy docker setting
apt-get install tor
apt-get install privoxy
nano /etc/privoxy/config
# forward-socks4 / socks-gw.example.com:1080 .
forward-socks4 / 127.0.0.1:9150 .
forward-socks5 / 127.0.0.1:9150 .
# forward-socks5t / 127.0.0.1:9050 .
# forwarded-connect-retries is mainly interesting for socks4a
# 6.8. socket-timeout
# Number of seconds after which a socket times out if no data is
# socket-timeout 300
socket-timeout 300
nano /etc/tor/torrc
SOCKSPort 9150 # Default: Bind to localhost:9050 for local connections.
service tor restart
service privoxy restart
apt-get install jq curl
echo $(curl -s http://ip-api.com/json | jq -r ".country,.city")
nano .bashrc
alias whereiam='echo $(curl -s http://ip-api.com/json | jq -r ".country,.city")'
alias x="export http_proxy='127.0.0.1:8118'"
alias dx="export http_proxy=''"
#after install tor and privoxy show error
-----------> "Err:10 http://deb.debian.org/debian buster-updates Release Unsupported proxy configured: 127.0.0.1://9999"
#solution add proxy to repository
root@docker:/etc/apt# cat /etc/apt/apt.conf.d/proxy.conf
Acquire::http::Proxy "http://127.0.0.1:9999/";
Acquire::https::Proxy "http://127.0.0.1:9999/";
next step :
sudo apt-get purge docker lxc-docker docker-engine docker.io
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo systemctl status docker
Set proxy in docker:
mkdir /etc/systemd/system/docker.service.d
/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=127.0.0.1:8118"
systemctl reload docker.service
mv /etc/systemd/system/docker.service.d/http-proxy /etc/systemd/system/docker.service.d/http-proxy.conf
systemctl show docker --property Environment
docker restarrt
whereiam
@morteza-mori
Copy link
Author

morteza-mori commented Feb 25, 2017

docker
docker run -itd --name=container1 busybox
docker network inspect bridge
iptables -t nat -A PREROUTING -s 172.18.0.3/32 -j MASQUERADE

#########################################################
docker top 7ca8f573c8ea

@morteza-mori
Copy link
Author

morteza-mori commented Aug 25, 2018

Introduction to Docker &

Kubernetes

Agenda

● Linux Containers
● Docker
● Kubernetes

Linux Containers

Linux Containers

Linux Containers (Cont.)

LXC is an operating-system-level virtualization method for
running multiple isolated Linux systems on a control host
using a single Linux kernel.

Linux Kernel Features used by Linux Containers

● Namespaces
(mnt, pid, net, ipc, uts/hostname, user ids)
● cgroups
(cpu, memory, disk, i/o - resource management)
● AppArmor, SELinux
(security/access control)
● seccomp
(computation isolation)
● chroot
(file system isolation)

More about Linux Containers

Docker

● A platform for managing Linux Containers
● Started in March, 2013
● Provided an easy to use API and powerful container image
management features
● Attracted the community very fast

Virtual Machines vs Docker

Docker is built on

● cgroup and namespacing capabilities of the Linux kernel
● Go programming language
(written in Go)
● Docker Image Specification
(for container image management)
● Libcontainer Specification
(namespaces, filesystem, resources, security, etc)

Docker is built on (Cont.)

Docker Architecture

Docker Image Structure

Problems with standalone Docker

● Running a server cluster on a set of Docker containers,
on a single Docker host is vulnerable to single point
of failure!

Kubernetes

● Kubernetes is a platform for hosting Docker containers in
a clustered environment with multiple Docker hosts
● Provides container grouping, load balancing,
auto-healing, scaling features
● Project was started by Google
● Contributors == Google, CodeOS, Redhat, Mesosphere,
Microsoft, HP, IBM, VMWare, Pivotal, SaltStack, etc

Kubernetes Components

Node Components

Node Components (Cont.)

● Docker is used in order to run your containers. rkt can
be used as an alternative to docker.
● Kubelet is an agent that runs on each node in the
cluster. It makes sure that containers are running in a
pod.
● Proxy is used for maintaining network rules and
performing connection forwarding.

Kubernetes Work Units

● Pod
● Service
● Label
● Deployment
● Ingress
● Persistent Volume
● ...

Pod

Pod is the most basic unit in Kubernetes. it represents a
unit of deployment.

Deployment

You tell a deployment your desired state (how many, how
fast, when) and it changes the actual state to the desired
state at a specified rate.

Deployment (Cont.)

Service

● Service groups together logical collections of pods that
perform the same function and presents them as a single
entity. It acts as a basic load balancer between pods.

Service (Cont.)

Minikube

Minikube

Minikube is a tool that makes it easy to run Kubernetes
locally. Minikube runs a single-node Kubernetes cluster
inside a VM on your laptop for users looking to try out
Kubernetes or develop with it day-to-day.

Resources

https://github.com/kubernauts/Kubernetes-Learning-Resources

@morteza-mori
Copy link
Author

@alirezamirzaeiyan واقعا ممنونم بابت آموزش خوبت

@morteza-mori
Copy link
Author

apt-get install docker
#show conteiner
docker pull ubuntu
docker ps -a
docker attach c1988b7b20c6
docker start c1988b7b20c6
https://mondedie.fr/viewtopic.php?pid=29034#p29034
https://training.docker.com/self-paced-training
DOCKER VS VAGRANT: http://stackoverflow.com/questions/16647069/should-i-use-vagrant-or-docker-for-creating-an-isolated-environment?rq=1
https://docs.docker.com/kitematic/nginx-web-server/
https://www.digitalocean.com/community/tutorials/docker-explained-how-to-containerize-and-use-nginx-as-a-proxy

docker
docker run -itd --name=container1 busybox
docker network inspect bridge
iptables -t nat -A PREROUTING -s 172.18.0.3/32 -j MASQUERADE

check process in docker
docker top 7ca8f573c8ea

@morteza-mori
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment