Skip to content

Instantly share code, notes, and snippets.

@zavod
Created April 9, 2019 13:01
Show Gist options
  • Save zavod/a8265e4ee4eec077ecb30dc770f31e85 to your computer and use it in GitHub Desktop.
Save zavod/a8265e4ee4eec077ecb30dc770f31e85 to your computer and use it in GitHub Desktop.
alp
@zavod
Copy link
Author

zavod commented Dec 30, 2019

manuals
https://docs.docker.com/v1.5/compose/django/
https://habrahabr.ru/post/272811/
http://blog.netczuk.pl/debugging-dockerized-python-django-app-with-pycharm/

docker version

docker -v

docker ps
docker images
docker-machine ls
docker-machine ssh default

create machine

docker-machine create --driver virtualbox default

remove machine

docker-machine rm swarm-agent-00

remove files of machine

rm -rf ~/.docker/machine/machines/public01

docker stop container

docker kill #

start/run docker-machine

docker-machine start swarm-master

#change active machine
eval $(docker-machine env scodev)

docker-compose build web

docker-compose up

docker-compose stop && docker-compose rm -f

#migrations
docker-compose run web /usr/local/bin/python manage.py migrate
docker-compose -f docker-compose-development.yml run django /usr/local/bin/python manage.py makemigrations report
docker-compose -f docker-compose-development.yml run web /usr/local/bin/python manage.py migrate

docker-compose -f docker-compose-release.yml run django /usr/local/bin/python manage.py migrate

create superuser

docker-compose run web /usr/local/bin/python manage.py createsuperuser

#macOS virtualbox
https://www.jetbrains.com/help/pycharm/5.0/configuring-remote-interpreters-via-docker.html

docker-compose stop && docker-compose rm -f && docker-compose build --no-cache web && docker-compose up -d

stop all containers

docker kill $(docker ps -q)

remove container

docker ps -a
docker rm -f 83c70025ba2c
sudo docker rm sco_web_run_2

docker ps -as

#remove images
docker rmi -f kldsfjkdjf

start helper

./build-core-django.sh

#start dev compose file
docker-compose -f docker-compose-development.yml up

start production

docker-compose -f docker-compose-release.yml up

start production assinchonly

docker-compose -f docker-compose-release.yml up -d

stop processes

docker-compose stop

check html

curl http://192.168.99.100:8080

#To see which environment variables are available to the web service, run:
docker-compose run web env

#logs
docker-compose logs

WINDOWS

https://msdn.microsoft.com/virtualization/hyperv_on_windows/quick_start/walkthrough_install

http://jayvilalta.com/blog/2016/04/28/installing-docker-toolbox-on-windows-with-hyper-v-installed/

env info

docker-compose run web env

logs

docker-compose logs

del old sha

docker-compose -f docker-compose-development.yml down

compile locale

docker-compose -f docker-compose-development.yml run django django-admin.py makemessages --all

docker-compose -f docker-compose-development.yml run django django-admin.py compilemessages

docker ssh

docker exec -it 70c6cd75522a bash

Delete all containers

docker rm $(docker ps -a -q)

Delete all images

docker rmi $(docker images -q)

#stop all docker containers
docker stop $(docker ps -a -q)

postgres backup

docker exec -it $(docker-compose ps -q postgres) pg_dump -postgres -p 5432 -U postgres sco > backup.sql

#swarm
#create virtualbox cluster
https://docs.docker.com/swarm/install-w-machine/

eval "$(docker-machine env --swarm swarm-master)"

swarm nodes

docker node ls

regenerate certificate swarm

docker-machine regenerate-certs swarm-agent-00

run tests

docker-compose -f docker-compose-development-2.yml run django_web /usr/local/bin/python manage.py test

docker network

docker network inspect $(docker network ls -q)

size docker

df -h /var/lib/docker/

empry table

docker ps
docker exec -it 70c6cd75522a bash
su postgres
psql
\connect postgres;
select count(*) from django_session;
TRUNCATE TABLE django_session;

docker no left space

docker volume rm $(docker volume ls -qf dangling=true)
docker volume ls -qf dangling=true
docker volume ls
docker rmi $(docker images | grep '^' | awk '{print $3}')

@zavod
Copy link
Author

zavod commented Mar 2, 2020

git rollback to commit

git reset --hard cedc856
git push --force origin master

@zavod
Copy link
Author

zavod commented Mar 18, 2020

@zavod
Copy link
Author

zavod commented Apr 4, 2020

brew find path

brew --prefix qt

@zavod
Copy link
Author

zavod commented May 13, 2020

@zavod
Copy link
Author

zavod commented Dec 26, 2020

MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
2020-12-26 05:42:07,663 ERROR Exception inside application: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

solution

redis-cli
config set stop-writes-on-bgsave-error no

restart

macOS (brew): brew services restart redis.
Linux: sudo service redis restart / sudo systemctl restart redis
Windows: Windows + R -> Type services.msc, Enter -> Search for Redis then click on restart.

@zavod
Copy link
Author

zavod commented Jun 15, 2021

Find process

grep -iR "smartsreda" /etc

@zavod
Copy link
Author

zavod commented Aug 25, 2021

display permissions of files and date

ls -l

@zavod
Copy link
Author

zavod commented Aug 26, 2021

memory usage by process

ps -o pid,user,%mem,command ax | sort -b -k3 -r

@zavod
Copy link
Author

zavod commented Aug 27, 2021

cpu usage by process

ps -o pid,user,%cpu,command ax | sort -b -k3 -r

@zavod
Copy link
Author

zavod commented Dec 20, 2021

add second ssh-key

cat id_rsa_one.pub >> authorized_keys

replace key

cat id_rsa_one.pub > authorized_keys

add second ssh-key to bitbucket

eval ssh-agent -s
ssh-add ~/.ssh/id_rsa_new

@zavodIT
Copy link

zavodIT commented Feb 22, 2023

Redis

set key

SET key1 "Hello"

get key value

get key1

del key

DEL key1

STREAM

add to stream

XADD mystream * name Sara surname OConnor

read from stream

XREAD COUNT 1 STREAMS mystream 3

del from stream

XTRIM mystream MAXLEN 0

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