Docker – none 컨테이너 삭제하기

$ docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
vpsdemop            latest              12473ad26899        2 minutes ago       1GB
<none>              <none>              84a6c05698e4        2 minutes ago       1GB
<none>              <none>              4011590a442e        3 minutes ago       1GB
<none>              <none>              fdf69123da65        3 minutes ago       1GB
...
<none>              <none>              b4a359727bd7        7 hours ago         112MB
ubuntu              20.04               1d622ef86b13        5 weeks ago         73.9MB
ubuntu              latest              1d622ef86b13        5 weeks ago         73.9MB

$ docker system prune
WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all dangling build cache
Are you sure you want to continue? [y/N] y
Deleted Containers:
8df4735033ad6cedf4a3231368a99ab4e2121d717f6d025bf2773ff6c755e197
e923e2b8076739edbb33c6d5bb9864346d0ba6b7882df148bcc831f65cc9db98
...
deleted: sha256:97ee249f1d92e909be67962aaab947390273413854f6d710b0fb279e1917b36a
deleted: sha256:8b4f5330ef79a9b5b369a9168d45a49604d02761229edf60e1aa125cf4030530

Total reclaimed space: 5.38GB

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
vpsdemop            latest              12473ad26899        3 minutes ago       1GB
ubuntu              20.04               1d622ef86b13        5 weeks ago         73.9MB
ubuntu              latest              1d622ef86b13        5 weeks ago         73.9MB

CentOS 7에 특정 버전의 Docker-CE 설치하기

$ yum remove docker docker-client docker-client-latest docker-common docker-latest                   docker-latest-logrotate docker-logrotate docker-engine
$ rm -rf /var/lib/docker/

$ sudo yum install -y yum-utils

$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ yum list docker-ce --showduplicates | sort -r
...
docker-ce.x86_64            3:19.03.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.11-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.10-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
...

$ yum install docker-ce-18.09.9 docker-ce-cli-18.09.9

$ docker --version
Docker version 18.09.9, build 039a7df9ba

$ systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

$ systemctl start docker
$ systemctl status docker

Ubuntu 12.04 에 Python 3.7 설치하기

사실 python 에서 protobuf3 를 사용할려면..
최신의 protobuf3 버전이 현재 python 3.7용만 설치가 되는듯하다..
기본 Ubuntu 12.04는 python이.. 3.8..

암튼.. python 3.7을 설치하려면 아래와 같이 하면됨.

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt install python3.7
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python3.7 get-pip.py

$ vim ~/.bashrc
alias pip='/home/ihmin/.local/bin/pip3.7'
alias python='/usr/bin/python3.7'

$ python --version
Python 3.7.7

$ pip --version
pip 20.1.1 from /home/ihmin/.local/lib/python3.7/site-packages/pip (python 3.7)

pip로 설치된 package는 아래에 설치됨.

/home/ihmin/.local/lib/python3.7/site-packages

CentOS 6.x 에 Python 3 버전 설치하기

$ yum install -y https://repo.ius.io/ius-release-el6.rpm
$ yum install -y python36u python36u-libs python36u-devel python36u-pip
$ python3.6 -V
Python 3.6.8
$ rm -f /usr/bin/python3
$ ln -s /usr/bin/python3.6 /usr/bin/python3
$ python3
Python 3.6.8 (default, Aug 10 2019, 06:52:10) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

opencv4nodejs 설치

우선 opencv4nodejs 를 설치하려면..
당연히 visual studio 타 기타 개발 툴들이 정상적으로 설치되어 있어야한다..
근데 착하게도.. node.js 용 네이티브 모듈을 설치하는데 필요한 개발툴을 자동으로 깔아주는 모듈이 있음..

https://github.com/felixrieseberg/windows-build-tools

우선 cmd를 관리자권한으로 실행하고..
아래를 실행하면 python이나 vs 같은 개발툴이 자동으로 설치가 된다..

C:\> npm install --global windows-build-tools

다음 아래를 실행하면 node.js용 opencv가 설치됨.

C:\> npm i opencv4nodejs 

CentOS 6 gcc 버전 업데이트

$ yum install centos-release-scl-rh centos-release-scl
$ yum check-update
$ yum install devtoolset-7-gcc-c++
$ source /opt/rh/devtoolset-7/enable
$ gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

아래도 가능..

yum install devtoolset-7-gcc-c++ (GCC 7.3.1)
yum install devtoolset-8-gcc-c++ (GCC 8.3.1)
yum install devtoolset-9-gcc-c++ (GCC 9.1.1)

아래와 같이 devtoolset-7-gcc-c++ 을 enable..

$ vim /etc/profile.d/enabledevtoolset-7.sh
#!/bin/bash
source /opt/rh/devtoolset-7/enable

LMDB

메모리에 통째로 올려 놓고 쓰는 작지만 아주 빠른 DB..
Key, Value 로 이루어진 심플한 DB..
쓰레드에 안전한 DB..
Fetch 시에 추가적인 시간이 들지 않는 빠른 DB.. (이미 메모리에 올려져있는 상태..)

http://www.lmdb.tech/
http://www.lmdb.tech/doc/index.html
https://github.com/LMDB/lmdb

자작 어플리케이션의 세션 저장용으로 쓰면 아주 좋을듯하다..
msys2의 pacman 패키지로도 설치 가능..

Crypto++ 을 이용한 암호화/복호화 예제

출처: https://lyb1495.tistory.com/25

가끔 텍스트 파일을 감추고 싶을때.. 이용하면 좋음.

#include <iostream>
#include <iomanip>

#include "cryptopp/cryptlib.h"
#include "cryptopp/modes.h"
#include "cryptopp/aes.h"
#include "cryptopp/filters.h"
#include "cryptopp/base64.h"

void hex2byte(const char *in, uint len, byte *out)
{
	for (uint i = 0; i < len; i+=2) {
		char c0 = in[i+0];
		char c1 = in[i+1];
		byte c = (
			((c0 & 0x40 ? (c0 & 0x20 ? c0-0x57 : c0-0x37) : c0-0x30)<<4) |
			((c1 & 0x40 ? (c1 & 0x20 ? c1-0x57 : c1-0x37) : c1-0x30))
			);
		out[i/2] = c;
	}
}

int main(int argc, char* argv[]) {
	// 키 할당
	byte key[CryptoPP::AES::DEFAULT_KEYLENGTH];
	memset(key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH );
	char* rawKey="f4150d4a1ac5708c29e437749045a39a";
	hex2byte(rawKey, strlen(rawKey), key);

	// 초기벡터 할당
	byte iv[CryptoPP::AES::BLOCKSIZE];
	memset(iv, 0x00, CryptoPP::AES::BLOCKSIZE );
	char* rawIv="86afc43868fea6abd40fbf6d5ed50905";
	hex2byte(rawIv, strlen(rawIv), iv);

	// 평문 할당
	std::string plaintext = "http://sopt.org/";
	std::string ciphertext;
	std::string base64encodedciphertext;
	std::string decryptedtext;
	std::string base64decryptedciphertext;

	// 평문 출력
	std::cout << "Plain Text (" << plaintext.size() <<
		" bytes)" << std::endl;
	std::cout << plaintext;
	std::cout << std::endl << std::endl;

	unsigned int plainTextLength = plaintext.length();

	// AES 암호화 수행
	CryptoPP::AES::Encryption 
		aesEncryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
	CryptoPP::CBC_Mode_ExternalCipher::Encryption 
		cbcEncryption(aesEncryption, iv);

	CryptoPP::StreamTransformationFilter 
		stfEncryptor(cbcEncryption, new CryptoPP::StringSink( ciphertext));
	stfEncryptor.Put(reinterpret_cast<const unsigned="" char*="">
		(plaintext.c_str()), plainTextLength + 1);
	stfEncryptor.MessageEnd();

	// Base64 인코딩
	CryptoPP::StringSource(ciphertext, true,
		new CryptoPP::Base64Encoder(
		new CryptoPP::StringSink(base64encodedciphertext)
		) // Base64Encoder
		); // StringSource

	// Base64 인코딩 문자열 출력
	std::cout << "Cipher Text (" << base64encodedciphertext.size() 
		<< " bytes)" << std::endl;
	std::cout << "cipher : " << base64encodedciphertext << std::endl;
	std::cout << std::endl << std::endl;

	// Base64 디코딩
	CryptoPP::StringSource(base64encodedciphertext, true,
		new CryptoPP::Base64Decoder(
		new CryptoPP::StringSink( base64decryptedciphertext)
		) // Base64Encoder
		); // StringSource

	// AES 복호화
	CryptoPP::AES::Decryption aesDecryption(key, 
		CryptoPP::AES::DEFAULT_KEYLENGTH);
	CryptoPP::CBC_Mode_ExternalCipher::Decryption 
		cbcDecryption(aesDecryption, iv );

	CryptoPP::StreamTransformationFilter 
		stfDecryptor(cbcDecryption, new CryptoPP::StringSink(decryptedtext));
	stfDecryptor.Put( reinterpret_cast<const unsigned="" char*="">
		(base64decryptedciphertext.c_str()), base64decryptedciphertext.size());
	stfDecryptor.MessageEnd();

	// 복호화 문자열 출력
	std::cout << "Decrypted Text: " << std::endl;
	std::cout << decryptedtext;
	std::cout << std::endl << std::endl;
	return 0;
}