Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
As you all may know pip is a python package manager and everyone has worked with it to install python libs.

Some of the commands with pip that you may not know about it:

- freeze: output installed packages in requirements format. (you can grep and search for a specific package):


rply==0.7.4
rsa==3.2.3
sasl==0.2.1
scipy==0.13.0b1



- list: list installed packages:

tcpwatch (1.3.1)
telebot (0.0.3)
thrift (0.9.3)



- show: Show information about installed packages:

$ pip show pandas
Name: pandas
Version: 0.17.0
Summary: Powerful data structures for data analysis, time series,and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: pydata@googlegroups.com
License: BSD
Location: /Library/Python/2.7/site-packages
Requires: numpy, python-dateutil, pytz


Important note for devops: pip by default install a stable version of the package. If you need to install an unstable version of the package (latest version) use --pre flag to install pre-release package.

If you want to manage your custom python repository package versions (RC, Alpha, Beta, Stable, etc) add classifiers to your setup.py script like below:

setup(...,
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: Web Environment',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Python Software Foundation License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python',
'Topic :: Communications :: Email',
'Topic :: Office/Business',
'Topic :: Software Development :: Bug Tracking',
],
)



The important part is Development Status :: 4 - Beta, which for stable release you would use Development Status :: 5 - Production/Stable.

To see list of pypi Development Status values read from the below link:
https://pypi.python.org/pypi?%3Aaction=list_classifiers

Now you can give versioning like Django 2.0b1 (for pre release) and Django 1.11.6 for stable release.
To see different classifiers see the link Django link below to learn more:
https://pypi.python.org/pypi/Django

#django #pip #pre_release #freeze #package #python #devops
PART-1: Basic docker commands

* Let's suppose you have built an image.

Display list of your docker images:
docker images


Output:
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
py_app latest baa470dc5609 3 weeks ago 591MB


As you can see image name is py_app.

To run the image:
docker run -it -d -p 8085:8084 py_app


The above command runs the docker image. The newly created processs by docker run from your py_app image is called a container. -d runs the image as a daemon and print the container id to your console:
$ docker run -it -d -p 8085:8084 py_app
d612ffbd9d560158f1c64997f9a8877243cdf4288c11010298df80b10cfaff5e


-p exposes the port on your docker file to the port on your host machine. The first port 8085 is the port on your
host, and the second port 8084 is the port on your docker file.

Now to see list of your containers use docker ps:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d612ffbd9d56 py_app "python app.py" 10 minutes ago Up 10 minutes goofy_hopper


From here you can see the ID of your container which is equal to d612ffbd9d56. IF you want to have a shell on your c
ontainer (login into container):
docker exec -it d612ffbd9d56  bash
root@moby:/app#


if you want to connect to the stdout of your container use attach, it does not necessary give you a shell:
docker attach d612ffbd9d56

*** IF you are attached to a container and press ^c afterward, the container will be stopped.

If you want to stop a container:
$ docker stop d612ffbd9d56
d612ffbd9d56


It prints out container id d612ffbd9d56 and stop the container. If you enter docker ps you should not see the container.

#docker #commands #docker_part1 #basic #container #devops
DevOps with Kubernetes
#devops #kubernetes