Commit 2567d3d0 authored by Ricardo Avila's avatar Ricardo Avila
Browse files

Merge branch 'authoring'

parents 20e0fcdb 227dcb1b
Pipeline #150355023 passed with stage
in 2 minutes and 25 seconds
......@@ -37,6 +37,8 @@ notes-nav:
url: /notes/python/pandas.html
- title: <i class="fas fa-laptop"></i> UNIX Stuff
children:
- title: BASH scripts
url: /notes/unix/bash-scripts.html
- title: Docker
url: /notes/unix/docker.html
- title: Flatpak
......
......@@ -7,9 +7,34 @@ sidebar:
nav: notes-nav
---
<!-- vim-markdown-toc GitLab -->
* [Environment Management](#environment-management)
<!-- vim-markdown-toc -->
## Environment Management
Updating all environment packages:
```
conda update --all
```
Cloning an environment:
```
conda create -n new-env --clone base
```
Exporting an environment:
```
conda env export | grep -v "^prefix: " > environment.yml
```
Re-creating an environment from a file:
```
conda env create -f environment.yml
```
---
layout: notes
title: Writing BASH Scripts
aside:
toc: true
sidebar:
nav: notes-nav
---
<!-- vim-markdown-toc GitLab -->
* [Starting scripts](#starting-scripts)
* [Set](#set)
<!-- vim-markdown-toc -->
This document collects basic syntax and best practices for writing
BASH scripts.
## Starting scripts
It is good practice to start BASH scripts with the following lines:
```bash
#!/bin/bash
set -euo pipefail
```
### Set
The command `set` allows you to change shell options. The most useful flags are:
-e
: Stop execution when an error is encountered.
You can "catch" an error to prevent the shell from exiting by appending `|| true` after a failing command.
-o pipefail
: Catch errors in pipes. Return zero exit status only if all commands in a pipeline succeed.
-u
: Error out when shell encounters undefined variables by their values.
-x
: Debug mode. Prints every line and output, substituting variables
-f
: Disable file globbing.
......@@ -7,17 +7,23 @@ sidebar:
nav: notes-nav
---
- [Installing Docker](#installing-docker)
- [Getting Docker Images](#getting-docker-images)
- [Running Containers](#running-containers)
- [Listing Containers in Docker](#listing-containers-in-docker)
- [Clearing Non-running Containers](#clearing-non-running-containers)
- [Mounting a Host Filesystem](#mounting-a-host-filesystem)
- [Fix for permissions issues:](#fix-for-permissions-issues)
- [Creating a Docker Image](#creating-a-docker-image)
- [By modifying an existing image](#by-modifying-an-existing-image)
- [Using a docker file](#using-a-docker-file)
- [Docker Compose](#docker-compose)
<!-- vim-markdown-toc GitLab -->
* [Installing Docker](#installing-docker)
* [Getting Docker Images](#getting-docker-images)
* [Running Containers](#running-containers)
* [Interacting with containers](#interacting-with-containers)
* [Listing Containers in Docker](#listing-containers-in-docker)
* [Clearing Non-running Containers](#clearing-non-running-containers)
* [Mounting a Host Filesystem](#mounting-a-host-filesystem)
* [Fix for permissions issues:](#fix-for-permissions-issues)
* [Creating a Docker Image](#creating-a-docker-image)
* [By modifying an existing image](#by-modifying-an-existing-image)
* [Using a docker file](#using-a-docker-file)
* [Docker Compose](#docker-compose)
<!-- vim-markdown-toc -->
## Installing Docker
......@@ -60,17 +66,30 @@ See installed images: `docker images`
Use `docker run` to run an application inside a container.
-d run in background (daemonize)
-i interactive
-t tty
--name give container a name
--rm remove container when it exits
Common options:
-d
: run in background (daemonize)
-i
: interactive
-t
: tty
--name
: assign container a name
--rm
: remove container when it exits
### Interacting with containers
Start a container (can use an assigned name): `docker start`
Stop a container: `docker stop`
Stop a container `docker stop`
execute a command off a running container: `docker exec`
Execute a command off a running container: `docker exec`
Look inside container: `docker logs`
......@@ -80,9 +99,13 @@ To show only running containers use:
docker container ls
Options:
-a see all containers
-s see container sizes
Options:
-a
: see all containers
-s
: see container sizes
## Clearing Non-running Containers
......@@ -110,7 +133,7 @@ The solution is to issue a SELinux rule:
This got easier recently since Docker finally merged a patch which will be showing up in docker-1.7 (We have been carrying the patch in docker-1.6 on RHEL, CentOS, and Fedora).
This got easier recently since Docker finally merged a patch in docker-1.7.
This patch adds support for "z" and "Z" as options on the volume mounts (-v).
......@@ -118,7 +141,7 @@ For example:
docker run -v /var/db:/var/db:z rhel7 /bin/sh
Will automatically do the `chcon -Rt svirt_sandbox_file_t /var/db` described in the man page.
Will automatically do the `chcon -Rt svirt_sandbox_file_t /var/db`.
Even better, you can use Z.
......@@ -127,9 +150,9 @@ Even better, you can use Z.
This will label the content inside the container with the exact MCS label that the container will run with, basically it runs `chcon -Rt svirt_sandbox_file_t -l s0:c1,c2 /var/db`,
where s0:c1,c2 differs for each container.
https://docs.docker.com/storage/volumes/
For more info: [https://docs.docker.com/storage/volumes/](https://docs.docker.com/storage/volumes/)
E.g. to run my powershell docker container with a mounted home directory:
**e.g.** to run my powershell docker container with a mounted home directory:
```
docker run -v /home/ravila/:/home/ravila/:Z -it mcr.microsoft.com/powershell
......
......@@ -12,6 +12,15 @@ A Curated List of My Favorite Blogs.
[Practical Cheminformatics](http://practicalcheminformatics.blogspot.com/)
## Software Development
[Thomas Kainrad](https://tkainrad.dev/)
## Linux
[GNOME Shell & Mutter](https://blogs.gnome.org/shell-dev/)
## Photography
[Paul Stamatiou](https://paulstamatiou.com/)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment