Subdirectories of docker mount not mounted correctly with docker-compose The Next CEO of Stack...
How did Beeri the Hittite come up with naming his daughter Yehudit?
Physiological effects of huge anime eyes
Is it ok to trim down a tube patch?
What is the process for cleansing a very negative action
Is there a difference between "Fahrstuhl" and "Aufzug"?
Does the Idaho Potato Commission associate potato skins with healthy eating?
What is the difference between "hamstring tendon" and "common hamstring tendon"?
Getting Stale Gas Out of a Gas Tank w/out Dropping the Tank
What happened in Rome, when the western empire "fell"?
What steps are necessary to read a Modern SSD in Medieval Europe?
What day is it again?
Won the lottery - how do I keep the money?
Reference request: Grassmannian and Plucker coordinates in type B, C, D
A question about free fall, velocity, and the height of an object.
Calculate the Mean mean of two numbers
Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?
What was Carter Burke's job for "the company" in Aliens?
Is a distribution that is normal, but highly skewed, considered Gaussian?
How to avoid supervisors with prejudiced views?
Graph of the history of databases
Is dried pee considered dirt?
Airplane gently rocking its wings during whole flight
Towers in the ocean; How deep can they be built?
Do scriptures give a method to recognize a truly self-realized person/jivanmukta?
Subdirectories of docker mount not mounted correctly with docker-compose
The Next CEO of Stack OverflowWhere is '/host' declared for mount in Wubi (Ubuntu 9.10)?Unable to mount external drive or sshfsWhat is a prescriptive way for managing the permissions for mounted volumes in Alpine-based Docker?docker-compose up/down just one containerMigrating from docker-compose v2 to v3Docker with /aufs on AWS EFS volume reports mount error “file too large”Docker Compose with an l2bridge compose fileDocker containers on multiple hosts with docker-composeVirtualbox & Docker, mount shared folderExFat USB-mount not updated in Docker container
Problem
Using a data container to store the MySQL data does not work properly if I mount the parent directory /var/lib instead of /var/lib/mysql
Infrastructure
I'm using 3 docker containers to provide a website:
- nginx container to run a webserver
- mariadb container for the database
- data container for the created user data
The data container is created using the following docker command:
$ docker create
-v /var/lib
-v /var/www
--name [appname]-data
tianon/true /bin/true
Checking the available mounts for [appname]-data with $ docker inspect [appname]-data
:
"Mounts": [
{
"Name": "361ed7b3e38371653f2df75652973e1c48db52d59c4c5371f634c1930291af0c",
"Source": "/var/lib/docker/volumes/361ed7b3e38371653f2df75652973e1c48db52d59c4c5371f634c1930291af0c/_data",
"Destination": "/var/lib",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
...
The containers are started with docker-compose. Both containers should use all mounts available on the data container. My docker-compose.yml:
[appname]-nginx:
container_name: [appname]-nginx
image: nginx:9-apache
links:
- [appname]-mariadb:mysql
volumes_from:
- [appname]-data
restart: always
expose:
- "80"
[appname]-mariadb:
image: mariadb:10.1
container_name: [appname]-mariadb
restart: always
volumes_from:
- [appname]-data
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
The output of $ docker exec -it [appname]-nginx ls -lha /var/lib/mysql
:
total 8.0K
drwxr-xr-x 2 root root 4.0K Jun 27 16:30 .
drwxr-xr-x 3 root root 4.0K Jul 21 10:19 ..
The output of $ docker exec -it [appname]-mariadb ls -lha /var/lib/mysql
:
total 109M
drwxr-xr-x 4 mysql mysql 4.0K Jul 21 10:19 .
drwxr-xr-x 3 root root 4.0K Jul 21 10:19 ..
-rw-rw---- 1 mysql mysql 16K Jul 21 07:57 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 Jul 21 07:57 aria_log_control
-rw-rw---- 1 mysql mysql 48M Jul 21 07:57 ib_logfile0
-rw-rw---- 1 mysql mysql 48M Jul 21 07:56 ib_logfile1
-rw-rw---- 1 mysql mysql 12M Jul 21 07:57 ibdata1
-rw-rw---- 1 mysql mysql 0 Jul 21 07:56 multi-master.info
drwx------ 2 mysql mysql 4.0K Jul 21 07:57 mysql
drwx------ 2 mysql mysql 4.0K Jul 21 07:56 performance_schema
-rw-rw---- 1 mysql mysql 24K Jul 21 07:57 tc.log
Executing mount
on both containers shows the same:
/dev/dm-0 on /var/lib type ext4 (rw,relatime,data=ordered)
/dev/dm-0 on /var/www type ext4 (rw,relatime,data=ordered)
However for [appname]-mariadb has an additional mount for /var/lib/mysql exists:
/dev/dm-0 on /var/lib/mysql type ext4 (rw,relatime,data=ordered)
Question
Why is it not possible to create a volume mount on /var/lib to save all stored data in the data container?
Do I miss something?
Is it a problem of MySQL / MariaDB?
mount docker
bumped to the homepage by Community♦ 52 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Problem
Using a data container to store the MySQL data does not work properly if I mount the parent directory /var/lib instead of /var/lib/mysql
Infrastructure
I'm using 3 docker containers to provide a website:
- nginx container to run a webserver
- mariadb container for the database
- data container for the created user data
The data container is created using the following docker command:
$ docker create
-v /var/lib
-v /var/www
--name [appname]-data
tianon/true /bin/true
Checking the available mounts for [appname]-data with $ docker inspect [appname]-data
:
"Mounts": [
{
"Name": "361ed7b3e38371653f2df75652973e1c48db52d59c4c5371f634c1930291af0c",
"Source": "/var/lib/docker/volumes/361ed7b3e38371653f2df75652973e1c48db52d59c4c5371f634c1930291af0c/_data",
"Destination": "/var/lib",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
...
The containers are started with docker-compose. Both containers should use all mounts available on the data container. My docker-compose.yml:
[appname]-nginx:
container_name: [appname]-nginx
image: nginx:9-apache
links:
- [appname]-mariadb:mysql
volumes_from:
- [appname]-data
restart: always
expose:
- "80"
[appname]-mariadb:
image: mariadb:10.1
container_name: [appname]-mariadb
restart: always
volumes_from:
- [appname]-data
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
The output of $ docker exec -it [appname]-nginx ls -lha /var/lib/mysql
:
total 8.0K
drwxr-xr-x 2 root root 4.0K Jun 27 16:30 .
drwxr-xr-x 3 root root 4.0K Jul 21 10:19 ..
The output of $ docker exec -it [appname]-mariadb ls -lha /var/lib/mysql
:
total 109M
drwxr-xr-x 4 mysql mysql 4.0K Jul 21 10:19 .
drwxr-xr-x 3 root root 4.0K Jul 21 10:19 ..
-rw-rw---- 1 mysql mysql 16K Jul 21 07:57 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 Jul 21 07:57 aria_log_control
-rw-rw---- 1 mysql mysql 48M Jul 21 07:57 ib_logfile0
-rw-rw---- 1 mysql mysql 48M Jul 21 07:56 ib_logfile1
-rw-rw---- 1 mysql mysql 12M Jul 21 07:57 ibdata1
-rw-rw---- 1 mysql mysql 0 Jul 21 07:56 multi-master.info
drwx------ 2 mysql mysql 4.0K Jul 21 07:57 mysql
drwx------ 2 mysql mysql 4.0K Jul 21 07:56 performance_schema
-rw-rw---- 1 mysql mysql 24K Jul 21 07:57 tc.log
Executing mount
on both containers shows the same:
/dev/dm-0 on /var/lib type ext4 (rw,relatime,data=ordered)
/dev/dm-0 on /var/www type ext4 (rw,relatime,data=ordered)
However for [appname]-mariadb has an additional mount for /var/lib/mysql exists:
/dev/dm-0 on /var/lib/mysql type ext4 (rw,relatime,data=ordered)
Question
Why is it not possible to create a volume mount on /var/lib to save all stored data in the data container?
Do I miss something?
Is it a problem of MySQL / MariaDB?
mount docker
bumped to the homepage by Community♦ 52 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Problem
Using a data container to store the MySQL data does not work properly if I mount the parent directory /var/lib instead of /var/lib/mysql
Infrastructure
I'm using 3 docker containers to provide a website:
- nginx container to run a webserver
- mariadb container for the database
- data container for the created user data
The data container is created using the following docker command:
$ docker create
-v /var/lib
-v /var/www
--name [appname]-data
tianon/true /bin/true
Checking the available mounts for [appname]-data with $ docker inspect [appname]-data
:
"Mounts": [
{
"Name": "361ed7b3e38371653f2df75652973e1c48db52d59c4c5371f634c1930291af0c",
"Source": "/var/lib/docker/volumes/361ed7b3e38371653f2df75652973e1c48db52d59c4c5371f634c1930291af0c/_data",
"Destination": "/var/lib",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
...
The containers are started with docker-compose. Both containers should use all mounts available on the data container. My docker-compose.yml:
[appname]-nginx:
container_name: [appname]-nginx
image: nginx:9-apache
links:
- [appname]-mariadb:mysql
volumes_from:
- [appname]-data
restart: always
expose:
- "80"
[appname]-mariadb:
image: mariadb:10.1
container_name: [appname]-mariadb
restart: always
volumes_from:
- [appname]-data
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
The output of $ docker exec -it [appname]-nginx ls -lha /var/lib/mysql
:
total 8.0K
drwxr-xr-x 2 root root 4.0K Jun 27 16:30 .
drwxr-xr-x 3 root root 4.0K Jul 21 10:19 ..
The output of $ docker exec -it [appname]-mariadb ls -lha /var/lib/mysql
:
total 109M
drwxr-xr-x 4 mysql mysql 4.0K Jul 21 10:19 .
drwxr-xr-x 3 root root 4.0K Jul 21 10:19 ..
-rw-rw---- 1 mysql mysql 16K Jul 21 07:57 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 Jul 21 07:57 aria_log_control
-rw-rw---- 1 mysql mysql 48M Jul 21 07:57 ib_logfile0
-rw-rw---- 1 mysql mysql 48M Jul 21 07:56 ib_logfile1
-rw-rw---- 1 mysql mysql 12M Jul 21 07:57 ibdata1
-rw-rw---- 1 mysql mysql 0 Jul 21 07:56 multi-master.info
drwx------ 2 mysql mysql 4.0K Jul 21 07:57 mysql
drwx------ 2 mysql mysql 4.0K Jul 21 07:56 performance_schema
-rw-rw---- 1 mysql mysql 24K Jul 21 07:57 tc.log
Executing mount
on both containers shows the same:
/dev/dm-0 on /var/lib type ext4 (rw,relatime,data=ordered)
/dev/dm-0 on /var/www type ext4 (rw,relatime,data=ordered)
However for [appname]-mariadb has an additional mount for /var/lib/mysql exists:
/dev/dm-0 on /var/lib/mysql type ext4 (rw,relatime,data=ordered)
Question
Why is it not possible to create a volume mount on /var/lib to save all stored data in the data container?
Do I miss something?
Is it a problem of MySQL / MariaDB?
mount docker
Problem
Using a data container to store the MySQL data does not work properly if I mount the parent directory /var/lib instead of /var/lib/mysql
Infrastructure
I'm using 3 docker containers to provide a website:
- nginx container to run a webserver
- mariadb container for the database
- data container for the created user data
The data container is created using the following docker command:
$ docker create
-v /var/lib
-v /var/www
--name [appname]-data
tianon/true /bin/true
Checking the available mounts for [appname]-data with $ docker inspect [appname]-data
:
"Mounts": [
{
"Name": "361ed7b3e38371653f2df75652973e1c48db52d59c4c5371f634c1930291af0c",
"Source": "/var/lib/docker/volumes/361ed7b3e38371653f2df75652973e1c48db52d59c4c5371f634c1930291af0c/_data",
"Destination": "/var/lib",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
...
The containers are started with docker-compose. Both containers should use all mounts available on the data container. My docker-compose.yml:
[appname]-nginx:
container_name: [appname]-nginx
image: nginx:9-apache
links:
- [appname]-mariadb:mysql
volumes_from:
- [appname]-data
restart: always
expose:
- "80"
[appname]-mariadb:
image: mariadb:10.1
container_name: [appname]-mariadb
restart: always
volumes_from:
- [appname]-data
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
The output of $ docker exec -it [appname]-nginx ls -lha /var/lib/mysql
:
total 8.0K
drwxr-xr-x 2 root root 4.0K Jun 27 16:30 .
drwxr-xr-x 3 root root 4.0K Jul 21 10:19 ..
The output of $ docker exec -it [appname]-mariadb ls -lha /var/lib/mysql
:
total 109M
drwxr-xr-x 4 mysql mysql 4.0K Jul 21 10:19 .
drwxr-xr-x 3 root root 4.0K Jul 21 10:19 ..
-rw-rw---- 1 mysql mysql 16K Jul 21 07:57 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 Jul 21 07:57 aria_log_control
-rw-rw---- 1 mysql mysql 48M Jul 21 07:57 ib_logfile0
-rw-rw---- 1 mysql mysql 48M Jul 21 07:56 ib_logfile1
-rw-rw---- 1 mysql mysql 12M Jul 21 07:57 ibdata1
-rw-rw---- 1 mysql mysql 0 Jul 21 07:56 multi-master.info
drwx------ 2 mysql mysql 4.0K Jul 21 07:57 mysql
drwx------ 2 mysql mysql 4.0K Jul 21 07:56 performance_schema
-rw-rw---- 1 mysql mysql 24K Jul 21 07:57 tc.log
Executing mount
on both containers shows the same:
/dev/dm-0 on /var/lib type ext4 (rw,relatime,data=ordered)
/dev/dm-0 on /var/www type ext4 (rw,relatime,data=ordered)
However for [appname]-mariadb has an additional mount for /var/lib/mysql exists:
/dev/dm-0 on /var/lib/mysql type ext4 (rw,relatime,data=ordered)
Question
Why is it not possible to create a volume mount on /var/lib to save all stored data in the data container?
Do I miss something?
Is it a problem of MySQL / MariaDB?
mount docker
mount docker
asked Jul 21 '16 at 12:31
lspcitylspcity
426146
426146
bumped to the homepage by Community♦ 52 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 52 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Why don't you create your docker volume from docker-compose.yml
as well?
The following should work:
version: '2'
services:
nginx:
image: nginx:9-apache
expose:
- '80'
volumes:
- app-data:/var/www
mariadb:
image: mariadb:10.1
volumes:
- app-data:/var/lib
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
volumes:
app-data:
I wonder why you'd want both containers to store their data on the same volume though. I'd imagine it preferable to store nginx
's and mariadb
's data in separate volumes.
add a comment |
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1103560%2fsubdirectories-of-docker-mount-not-mounted-correctly-with-docker-compose%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Why don't you create your docker volume from docker-compose.yml
as well?
The following should work:
version: '2'
services:
nginx:
image: nginx:9-apache
expose:
- '80'
volumes:
- app-data:/var/www
mariadb:
image: mariadb:10.1
volumes:
- app-data:/var/lib
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
volumes:
app-data:
I wonder why you'd want both containers to store their data on the same volume though. I'd imagine it preferable to store nginx
's and mariadb
's data in separate volumes.
add a comment |
Why don't you create your docker volume from docker-compose.yml
as well?
The following should work:
version: '2'
services:
nginx:
image: nginx:9-apache
expose:
- '80'
volumes:
- app-data:/var/www
mariadb:
image: mariadb:10.1
volumes:
- app-data:/var/lib
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
volumes:
app-data:
I wonder why you'd want both containers to store their data on the same volume though. I'd imagine it preferable to store nginx
's and mariadb
's data in separate volumes.
add a comment |
Why don't you create your docker volume from docker-compose.yml
as well?
The following should work:
version: '2'
services:
nginx:
image: nginx:9-apache
expose:
- '80'
volumes:
- app-data:/var/www
mariadb:
image: mariadb:10.1
volumes:
- app-data:/var/lib
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
volumes:
app-data:
I wonder why you'd want both containers to store their data on the same volume though. I'd imagine it preferable to store nginx
's and mariadb
's data in separate volumes.
Why don't you create your docker volume from docker-compose.yml
as well?
The following should work:
version: '2'
services:
nginx:
image: nginx:9-apache
expose:
- '80'
volumes:
- app-data:/var/www
mariadb:
image: mariadb:10.1
volumes:
- app-data:/var/lib
environment:
MYSQL_ROOT_PASSWORD: pas$w0rd
TERM: dumb
volumes:
app-data:
I wonder why you'd want both containers to store their data on the same volume though. I'd imagine it preferable to store nginx
's and mariadb
's data in separate volumes.
answered Mar 29 '18 at 17:09
MartinMartin
7316
7316
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1103560%2fsubdirectories-of-docker-mount-not-mounted-correctly-with-docker-compose%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown