Commit 08f5209b authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.

Initial commit

parents
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\fs24 \cf0 No work files for this lesson...}
\ No newline at end of file
FROM debian:jessie
RUN mkdir /vol && touch /vol/file1
VOLUME /vol
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
long long readLongFile(char *file) {
FILE *f = fopen(file, "r");
if (!f) {
return -1;
}
char buffer[30]; // enough to contain "9223372036854771712" (20 chars) with some give
size_t bytes = fread(buffer, sizeof(*buffer), sizeof(buffer), f);
fclose(f);
if (bytes < 1) {
return -1;
}
buffer[bytes] = 0;
return atoll(buffer);
}
void printMemUsage() {
double usage = readLongFile("/sys/fs/cgroup/memory/memory.usage_in_bytes") / 1024.0 / 1024.0;
double limit = readLongFile("/sys/fs/cgroup/memory/memory.limit_in_bytes") / 1024.0 / 1024.0;
printf("current usage within memory cgroup: %.02f MB / %.02f MB\n", usage, limit);
}
void forceMalloc(size_t bytes) {
printf("malloc: %zu MB", bytes / 1024 / 1024);
size_t ints = bytes / sizeof(int);
int *ptr = malloc(bytes);
size_t i;
for (i = 0; i < ints; ++i) {
ptr[i] = rand();
}
printf("\n");
}
int main() {
printMemUsage(); // ~ 0 MB
forceMalloc(100 * 1024 * 1024);
printMemUsage(); // ~ 100 MB
forceMalloc(100 * 1024 * 1024);
printMemUsage(); // ~ 200 MB
return 0;
}
version: '2'
services:
wordpress_db:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: password
wordpress:
depends_on:
- wordpress_db
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: wordpress_db
WORDPRESS_DB_PASSWORD: password
{
"docker.": {
"type": "containers",
"socket": "unix:///var/run/docker.sock"
},
"local.": {
"type": "forwarding",
"nameservers": [ "192.168.1.1" ]
},
".": {
"type": "forwarding",
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
}
}
#Must run with '--priviledged' flag, and /var/run/docker.sock mounted.
FROM docker:1.11
COPY root /var/spool/cron/crontabs/root
RUN chmod 0644 /var/spool/cron/crontabs/root
VOLUME /backup
CMD crond -f -d 0
version: '2'
services:
logstash:
image: logstash:2.3
restart: always
command: [
'-e',
'
input {
gelf {
}
}
output {
elasticsearch {
hosts => "elasticsearch:9200"
}
}
',
]
expose:
- 12201/udp
- 5000/tcp
ports:
- 12201:12201/udp
- 5000:5000/tcp
elasticsearch:
image: elasticsearch:2.3
restart: always
kibana:
image: kibana:4.5
restart: always
ports:
- 5601:5601
#!/bin/bash
set -e
# allow postgres flags to be passed on the docker run
#if [ "${1:0:1}" = '-' ]; then
# set -- postgres "$@"
#fi
if [ "$1" = 'postgres' ]; then
# look specifically for PG_VERSION, as it is expected in the DB dir
if [ ! -s "$PGDATA/PG_VERSION" ]; then
initdb
#initdb $POSTGRES_INITDB_ARGS
# setup an access control file
{ echo; echo "host all all 0.0.0.0/0 trust"; } >> "$PGDATA/pg_hba.conf"
# WARNING this config is VERY insecure
fi
fi
exec "$@"
FROM debian:jessie
# explicitly set user/group IDs
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
# add the gpg key for apt.postgresql.org apt repos
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# specify a version
ENV PG_MAJOR 9.5
ENV PG_VERSION 9.5.3-1.pgdg80+1
# add the repo to our apt sources
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
# install postgres, pinning to a specific version
# also make sure it doesn't try to initialize the database
RUN apt-get update \
&& apt-get install -y postgresql-common \
&& sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \
&& apt-get install -y \
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
&& rm -rf /var/lib/apt/lists/* \
# listen on all interfaces
&& sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample
# add postgres binaries to the PATH for ease of use
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
# setup directories for data and run (pid file)
ENV PGDATA /var/lib/postgresql/data
RUN mkdir -p /var/run/postgresql "$PGDATA" && chown -R postgres /var/run/postgresql "$PGDATA"
# volume for the database files
VOLUME /var/lib/postgresql/data
# add our custom entrypoint to the path for ease of use
COPY docker-entrypoint.sh /usr/local/bin/
# step down from root
USER postgres
# set our entrypoint and cmd
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["postgres"]
* * * * * sh -c 'docker run --net=mysql_net --rm mysql bash -c "mysqldump --host=some-mysql --user=root --password='my-secret-pw' --all-databases" > "/backup/$(date +%F\[%T\]).sql"'
Due to ongoing efforts to ensure you have the best possible learning experience, we may update the working files for this course from time to time.
We recommend that you download the latest version of these files from:
http://www.infiniteskills.com/02393
\ No newline at end of file
## Example files for the title:
# Advanced Containerization, by Talon Bowler
[![Advanced Containerization, by Talon Bowler](http://akamaicovers.oreilly.com/images/9781491959305/cat.gif)](https://www.safaribooksonline.com/library/view/title/9781491959312//)
The following applies to example files from material published by O’Reilly Media, Inc. Content from other publishers may include different rules of usage. Please refer to any additional usage rights explained in the actual example files or refer to the publisher’s website.
O'Reilly books are here to help you get your job done. In general, you may use the code in O'Reilly books in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from our books does not require permission. Answering a question by citing our books and quoting example code does not require permission. On the other hand, selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Incorporating a significant amount of example code from our books into your product's documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at <permissions@oreilly.com>.
Please note that the examples are not production code and have not been carefully testing. They are provided "as-is" and come with no warranty of any kind.
logo.png

9.2 KB

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