From easy git installation to docker startup python

What is this?

A memorandum for me who forgets to work I plan to operate git from pycharm If you do this, you will be able to work without polluting your computer.

So do it Do it anyway

Introducing git

I hope git can be used because it is convenient in many ways.

1. Installation

First, download Git from the following site https://git-for-windows.github.io/

After that, if you follow the road, the installation is completed The detailed route is difficult to explain, so check it out.

2. Register user name and email address

At the console $ git config --global user.name" username " $ git config --global user.email" email address "` Type in to complete registration

Work on github side

Create a github account, go to the github homepage and create a repository with new repository from "+" on the upper right Decide the name by Repository name Decide whether it is public or private and click create repository

Then a meaningful url will appear on the screen, so copy it and go to the terminal

image.png (51.7 kB)

You can issue a url even from Code, so let's do it from here when cloning

Go to the directory where you want to put your git project and git clone <url> By doing this, a directory connected to git will be created, so open pycharm or anything

Create .gitignore

The directory is completed, but as it is, anything will be shared on github, so create .gitignore Create a file named .gitignore directly under the directory

https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore If you are using JetBeain series IDE, copy and paste the above source code I don't know about other IDEs

Add the path of the file you do not want to share here This will prevent git from sharing files that you don't want to share with others, such as notes.

Work on the Docker side

After finishing the work on the github side, the next work is docker

Installation

This is packed with everything from installing Docker for desktop to linking with pycharm. https://qiita.com/Denpa_Ghost/items/caeddaa29bd9d7514cce

Create docker-compose.yml

Create docker-conpose.yml directly under the directory and copy and paste the following

docker-compose.yml


 version: '3'
services:
  app:
    build: docker/python
    tty: true
    volumes:
    - ./app/:/app
    working_dir: /app

build: specifies the storage destination of dockerfile

Whether tty: will be in a standby state after startup Required because it will fall immediately if there is nothing moving with false or blank

volumes: has the role of connecting the folder of the host machine and the folder in the container. The left is the host machine, the right is inside the container If there is no folder on the host side, a new folder will be created.

working_dir: specifies the default working area

Creating dockerfile

After creating docker-compose.yml, create dockerfile in the path specified by build: If you want to run the slack bot, copy and paste the following

dockerfile


FROM python:latest
RUN mkdir -p /app
RUN pip install slackbot

FROM sets docker image RUN is the command to be entered after the container is created. Use it when you want to include other packages that are not included in docker image.

In the above case, after creating the container, create the app directory and install the slackbot package. You can do anything you can do mainly with a linux terminal

Creating a container

Once you get here, all you have to do is make a container In the directory where docker-compose.yml is located docker-compose up --build -d You can create a container by doing

First start docker-compose up --build -d

from next time docker-compose up -d Stop all containers docker-copose stop

Erase all containers docker-compose down

Erase containers and images together docker-compose down --rmi

Run .py

When you want to make a program and execute it Copy the name of the container you want to run with docker ps docker exec -it <name> bash You can access the terminal inside the container with After that, execute python normally with python main.py etc.

If you want to run without accessing the terminal docker exec -it <name> <program name> Can be executed without entering the terminal with

At the end

If you have any questions or complaints, please contact Arakawa It may or may not correspond

Enjoy a comfortable python life with this!

Recommended Posts

From easy git installation to docker startup python
[Note] [PyTorch] From installation to easy usage
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Try using the Python web framework Django (1)-From installation to server startup
An easy way to call Java from Python
From Kafka to KSQL --Easy environment construction with docker
Post from Python to Slack
Docker Easy Installation Procedure (CentOS)
Cheating from PHP to Python
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Switch from python2.7 to python3.6 (centos7)
Connect to sqlite from python
Call Matlab from Python to optimize
From Elasticsearch installation to data entry
Easy way to customize Python import
I tried to touch Python (installation)
Post from python to facebook timeline
[Lambda] [Python] Post to Twitter from Lambda!
Connect to utf8mb4 database from python
OpenMPI installation from download to pass-through
Python (from first time to execution)
Easy to use Jupyter notebook (Python3.5)
How to access wikipedia from python
Easy Python to learn while writing
Review from git init to git push
Did not change from Python 2 to 3
[Python Tutorial] An Easy Introduction to Python
Update Python on Mac from 2 to 3
git / python> git log analysis (v0.1, v0.2)> Implementation to estimate work time from git log
From ubuntu installation to running kinect with docker and ros (overview)
[Python] Fluid simulation: From linear to non-linear
From Python to using MeCab (and CaboCha)
[Linux] Flow from power-on to PC startup
How to update Google Sheets from Python
Send a message from Python to Slack
Python installation
Private Python handbook (updated from time to time)
Connect to MySQL with Python within Docker
Convert from katakana to vowel kana [python]
Push notification from Python server to Android
Easy way to use Wikipedia in Python
Connecting from python to MySQL on CentOS 6.4
Porting and modifying doublet-solver from python2 to python3.
How to access RDS from Lambda (python)
Launch the Python interpreter from Git bash
Python installation
Python> Output numbers from 1 to 100, 501 to 600> For csv
Flask tutorial (from installation to hello world)
Introducing Docker Engine to Linux From Scratch
Convert from Markdown to HTML in Python
[Amazon Linux] Switching from Python 2 series to Python 3 series
API explanation to touch mastodon from python
Introduction to Scapy ① (From installation to execution of Scapy)
Connect to coincheck's Websocket API from Python
How to install python3 with docker centos
python Binary search It is surprisingly easy to implement bisect.bisect_left and bisect.bisect_right from 0
[2021 version] From Selenium Basic installation to Web scraping execution by Python Windows 10 (64bit)
Python beginners tried it in 3 days from OS installation to running Twitter API
How to upload with Heroku, Flask, Python, Git (4)
[Python] Easy introduction to machine learning with python (SVM)