To protect your USB-stick with a password you have to format it first with the Disk Utility program to the Mac OS Extended (Journaled) format with the GUI-Partitiontable.

Attention Please make a backup before you’re formatting it!!!

Then just go into the terminal and enter diskutil list. Here should see the USB drive listed (in my case it’s /dev/disk2)

In case you’ve only one partition on this USB stick you’ve to convert disk2s2 to a AppleCoreStorage with using you own passphrase. You can do this with the following command.

1
diskutil cs convert disk2s2 -passphrase yoursupersecurepassphrase

After some minutes the USB stick should be remounted and it’s protect with the passphrase of your choice. When you want you can save the passphrase in your local keychain so that you don’t have to enter it always again.

But in case that someone will “find” your USB-stick, he’ll have no access to the data that are stored on it without knowing the passphrase.

Comment and share

For some reasons it could be necessary to execute a job in scheduled time.
When running the job within a Docker container there’re two ways to do this.

The first would be to create a cron job on the server on which Docker is
running and let them execute the job with docker run.

The second way would be to let do everything within the Docker container.
But you don’t need to implement any scheduling functionality since it’s out of
the box available from any Linux based container.

For example when your container is using the tiny Alpine base image you can use
crond for it. The following code snippets are showing you everything what
is todo.

run.sh

1
2
3
4
5
#!/bin/sh
NOW=$(date +"%T")
echo "Hello from the job at ${NOW} in $(pwd)" >> /dev/stdout

Dockerfile

1
2
3
4
5
6
FROM alpine:latest
COPY ./job.sh /etc/periodic/15min/job
RUN chmod +x /etc/periodic/15min/job
CMD ["crond", "-fS"]

The dockerfile is doing two things. It’s copying the job.sh into a
predefined folder and mark them as executable.

All scripts that are within this folder will be executed by
crond every 15 minutes. There’re more predefined folders under
etc/periodic to let run a job hourly, daily, weekly or once per month.
In case you need more flexibility you’ve to change the crontabs file for the
root user manually.

The program crond comes with the tiny Alpine image but it will not be
executed automatically as a background daemon.

It’s possible to let run crond as a foreground process, which is intersting
for us. Since we need a process wich is running always, otherwise our Docker
container will be finished immdiately after it was started. So with giving
dockerd the -f flag as argument it will run constantly as a foreground
process and our Docker container will also running continuously.

Please keep in mind that it’s required that the script in the targetfolder
don’t have the .sh extension, otherwise run-parts which is used from
crond, will not use your script.

Please keep also in mind that the workingdirectory where the job.sh will be
executed is the /root folder. So maybe you’ve to change
the working directory in the job.sh at first before executing whatever
you’ve to execute…

Comment and share

  • page 1 of 1

Jan Baer

I’m a passionated Softwaredeveloper from Munich.


Softwaredeveloper


Germany