Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Tech C**P
Having local git repository server is easy enough by using docker and open source git lab project: docker pull gitlab/gitlab-ce #gitlab #open_source #docker
After pulling image into docker repository run the image using the command below:

sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest

Reference:
https://docs.gitlab.com/omnibus/docker/README.html

#gitlab #docker #image #docker_run
Pass arguments to Dockerfile when you build it using --build-arg in order to have greater flexibility on docker build:
docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg SHARDS_NO=5

If you want to pass multiple arguments to Dockerfile give another --build-arg and give your second argument as above.
Now initiate your args inside of Dockerfile as below:
ARG SHARDS_NO=""

#docker #container #build_arg #argument #build #image
In order to remove docker images, first see your images and their corresponding id:
sudo docker images
Now to remove an image just use rmi as below:
sudo docker rmi b0c8cfb8fdb3

b0c8cfb8fdb3 is IMAGE ID to be removed.

#docker #image #rmi #remove
In docker you export an image into a tar file and then import that image without ever needing to download it again from docker hub.

To export an image you need to know the image name in your host (you can get image name by listing all images using docker images):
—------------------------—
docker save python > python.tar

—------------------------—

python is an image name in docker hub that we have downloaded it once from the hub registry. Now after using save command you will have a .tar file in your current path.

If you want to import this images in another server or in case all your images have been removed from your host server or local server, you just need to use load command to load the image into your local docker registry:
—------------------------—
docker load -i python.tar

—------------------------—

You need to be in the path that python.tar file exists.
Now after loading the image you can see that the image is added to your local registry. To check that use docker images

#docker #import #export #save #load #registry #hub #image
Let's run a MySQL instance on our local machine using docker. You don't need to install any version of mysql on your system. You won't get into trouble of upgrading the mysql or even in the trouble of removing it.

When you stop the container Mysql will be stopped. If you remove the image it will be gone forever :)

To run an instance of mySQL on your system (server or desktop), just use the below command:
docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

NOTE: we assume that docker is installed on your system.

-p 3306:3306 will bind the container port into a port in host machine. We run it on 3306, if you have to change it you need to change the first port number to a port in your host like 3350:3306.

--name gives a name to you container, so you can easily work with the name provided.

-e will set an environment variable. Here we have set a password for our mysql root user.

-d makes the container to be run in DAEMON mode (in background).

mysql:latest this is the image name that you will pull from docker hub registry.

Voila! You are up & running we a totally working mysql server.

Let's check with netstat (on your HOST) whether it's up or not:
root@infra:~# netstat -nltp | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 11572/docker-proxy

#docker #mysql #netstat #image #container
Virt-builder is a tool for quickly building new virtual machines. You can build a variety of VMs for local or cloud use, usually within a few minutes or less. Virt-builder also has many ways to customize these VMs. Everything is run from the command line and nothing requires root privileges, so automation and scripting is simple.

To see available virtual machines:

virt-builder --list


Sample command to create a debian-9 image:

sudo virt-builder debian-9 --size=50G --hostname prod.example.com --network --install network-manager --root-password password:YOUR_PASS


The above command creates a debian 9 image with disk size of 50GB and sets the hostname to prod.example.com. --network enables the networking on guest and --install installs packages on the target O
S. The last parameter sets the root password to YOUR_PASS.

To read more about the axtra parameters:
- http://libguestfs.org/virt-builder.1.html

#linux #sysadmin #virt_builder #debian #image