Skip to content

Instantly share code, notes, and snippets.

View elowy01's full-sized avatar

Ernesto Lowy elowy01

  • Biofidelity
  • Cambridge, UK
View GitHub Profile
# You need a .yaml file with the stack definition:
version: '3'
services:
fruit:
image: linuxacademycontent/fruit-service:1.0.1
vegetables:
image: linuxacademycontent/vegetable-service:1.0.0
all_products:
image: linuxacademycontent/all-products:1.0.0
ports:
Bind Mounts vs. Volumes
When mounting external storage to a
container, you can use either a bind
mount or a volume.
Bind mounts
-Mount a specific path on the host
machine to the container.
@elowy01
elowy01 / images.txt
Last active December 14, 2022 16:31
### Image cleanup
# Gives an idea on how the space is being used
cloud_user@elowy1c:~$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 1 1 1.22MB 0B (0%)
Containers 4 0 0B 0B
Local Volumes 1 0 0B 0B
Build Cache 0 0 0B 0B
###### Create a bridge network and demonstrate that two containers can
###### communicate using the network.
# Create network named my-net
$ docker network create my-net
# Run container using my-net network . It will have curl installed
# and will demonstrate that this container can access a different
# container on the same network
$ docker run -d --name my-net-busybox --network my-net radial/busyboxplus:curl sleep 3600
# create a second container running the nginx image
$ docker run -d --name my-net-nginx nginx
# H1
## H2
### H3
#### H4
##### H5
###### H6
Alternatively, for H1 and H2, an underline-ish style:
Alt-H1
# 1) Get the docker image for MYSQL server
$ docker pull mysql/mysql-server:latest
# 2) After download finished, you can see it through the docker image command:
$ docker images
# 3) We can create a container from this image:
$ docker run --name=mysql1 -d mysql/mysql-server
# 4) We can check the container logs by doing:
$ docker logs mysql1
# 5) If you only want to access it locally, it’s enough, but if you want to
# access your mysql server remotely, you need mapping the port 3306 of the
# First, install the following module:
$ [sudo] gem install terminal-notifier
# And write code:
import os
# The notifier function
def notify(title, subtitle, message):
t = '-title {!r}'.format(title)
s = '-subtitle {!r}'.format(subtitle)
# Example extracted from :
https://github.com/iamdvr/prepopulated-mysql-container-example
### The DockerFile is :
FROM mariadb:latest as builder
# That file does the DB initialization but also runs mysql daemon, by removing the last line it will only init
RUN ["sed", "-i", "s/exec \"$@\"/echo \"not running $@\"/", "/usr/local/bin/docker-entrypoint.sh"]
# needed for intialization
# Providing auth in Request
requests.get('https://api.github.com', auth=(username, pwd))
## Downloading a file
# Excellent article on:
https://www.codementor.io/@aviaryan/downloading-files-from-urls-in-python-77q3bs0un
import requests
resp = requests.get("http://www.example.com", allow_redirects=True)
## Reading as text
""" NOTES:
- requires Python 2.4 or greater
- elements of the lists must be hashable
- order of the original lists is not preserved
"""
def unique(a):
""" return the list with duplicate elements removed """
return list(set(a))
def intersect(a, b):