label studio persistent project with docker - docker

I am trying to setup a docker compose file in such a way that when I restart an image of label studio, I don't lose the project that I have created previously. Is there some way of doing this, either by having a volume set to a specific place or having some sort of file that label studio can use on start up to help define projects? This is my current docker compose file:
lab_studio:
build:
context: .
dockerfile: label_studio.Dockerfile
container_name: label_studio
image: label_studio
environment:
- LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
- LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/
ports:
- '8080:8080'
volumes:
- ./data:./data:rw
Thanks

I had to add the path that appears in the first few lines when the server starts up. In the case of the docker image, for the compose I had to add the following line in volumes:
- ./labelstudio:/root/.local/share/label-studio:rw

Related

How do I access odoo files (such as installed add-ons folder)?

I've set up Odoo 15 on a container with docker compose, and am accessing the container through remote container extension on VS code, I've looked everywhere I can't seem to get how to access the odoo files such as the installed add-ons folder
I've set up my volumes in docker-compose file pretty much in this way:
version: '3'
services:
odoo:
image: odoo:15.0
env_file: .env
depends_on:
- postgres
ports:
- "127.0.0.1:8069:8069"
volumes:
- data:/var/lib/odoo
- ./config:/etc/odoo
- ./extra-addons:/mnt/extra-addons
But since I would like to apply changes on the html/css of non custom add-ons that are already present in odoo I'd have to access the source code of odoo that is present in the container (if doable).
For example in the volume odoo-addons:/mnt/extra-addons would be a directory where i could add my custom module but what i want is to find the source code of the add-ons already present in Odoo ?!
Use named volumes - it will copy the existing data from the container image into a new volume. In docker-compose you can do it, by defining a volume:
version: '2'
volumes:
data:
services:
odoo:
image: odoo:15.0
env_file: .env
depends_on:
- postgres
ports:
- "127.0.0.1:8069:8069"
volumes:
- data:/var/lib/odoo
- ./config:/etc/odoo
- ./extra-addons:/mnt/extra-addons
If your files reside in the /var/lib/odoo folder you will be able to view/edit the files which are thereby accessing them in the /var/lib/docker/volumes/{someName}_data/_data

Docker containers are recreated instead of creating new instance [duplicate]

This question already has an answer here:
Docker is not creating new container but recreates running one
(1 answer)
Closed 1 year ago.
I wanted to use docker-compose to spin up new instances of my containers, but with slightly different parameters, so I essentially copied the entire project folder, made changes to my Docker compose file, and did docker-compose up --build but no matter which project folder I run that in, it only recreates the containers rather than spinning up new ones.
Below is my compose file. In one project folder it's this, and in the other, I changed container-name to app-test-client and app-test-api as well as changing the ports (e.g. 8080:80), so why does it recreate instead of spinning up new containers? I want to see both app-client and app-test-client running.
version: '3.2'
services:
client:
build:
context: ./client
container_name: app-client
ports:
- '80:80'
- '5432:5432'
- '443:443'
links:
- api
api:
build:
context: ./api
container_name: app-api
volumes:
- ~/.ssh:/root/.ssh
environment:
# read from ./.env file if it exists
- EDR_ENVIRONMENT=${EDR_ENV}
- SAS_ENVIRONMENT=${SAS_ENV}
command: ['node', '.']
The name is based on the service name, not the container name.
version: '3.2'
services:
client-test:
...
links:
- api
api-test:
...
You can also pass the parameter p to change the project name

Docker container not updating on code change

I have a Dockerfile to build my node container, it looks as follows:
FROM node:12.14.0
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 4500
CMD ["npm", "start"]
based on this docker file, I am using docker compose to run this container and link it to a mongo container such that it refers to mongo-service. The docker-compose.yml looks as follows
version: '3'
services:
backend:
container_name: docker-node-mongo-container
restart: always
build: .
ports:
- '4700:4500'
links:
- mongo-service
mongo-service:
container_name: mongo-container
image: mongo
ports:
- "27017:27017"
Expected behavior: Everytime I make a new change to the project on my local computer, I want the docker-compose to restart so that the new changes are reflected.
Current behavior: To make the new changed reflect on docker-compose, I have to do docker-compose down and then delete images. I am guessing that it has to rebuild images. How do I make it so that whenever I make change, the dockerfile builds a new image?
I understand that need to use volumes. I am just failing to understand how. Could somebody please help me here? docker
When you make a change, you need to run docker-compose up --build. That will rebuild your image and restart containers as needed.
Docker has no facility to detect code changes, and it is not intended as a live-reloading environment. Volumes are not intended to hold code, and there are a couple of problems people run into attempting it (Docker file sync can be slow or inconsistent; putting a node_modules tree into an anonymous volume actively ignores changes to package.json; it ports especially badly to clustered environments like Kubernetes). You can use a host Node pointed at your Docker MongoDB for day-to-day development, and still use this Docker-based setup for deployment.
In order for you to 'restart' your docker application, you need to use docker volumes.
Add into your docker-compose.yml file something like:
version: '3'
services:
backend:
container_name: docker-node-mongo-container
restart: always
build: .
ports:
- '4700:4500'
links:
- mongo-service
volumes:
- .:/usr/src/app
mongo-service:
container_name: mongo-container
image: mongo
ports:
- "27017:27017"
The volumes tag is a simple saying: "Hey, map the current folder outside the container (the dot) to the working directory inside the container".

File in docker volume not updating

Hi I have a Nifi docker container stopped and I want to update a property file.
Whenever I update a field, when I run docker-compose start it doesn't update the property file.
How can this be possible?
here is my docker compose:
version: "3.3"
services:
nifi:
image: apache/nifi
volumes:
- /home/ubuntu/nifi/conf:/opt/nifi/nifi-current/conf
ports:
- "8080:8080"
Thanks
We had this issue a while back as well. I believe using volumes essentially creates a symlink, and when the container starts up it overwrites anything in that folder.
Have you considered creating a multistage build? That was our solution:
Dockerfile:
FROM apache/nifi:1.9.2
ADD /path/to/your-props.properties /opt/nifi/nifi-current/conf
We then put the resulting image in our compose

Building and uploading images to Docker Hub, how to from Docker Compose?

I have been working in a docker environment for PHP development and finally I get it working as I need. This environment relies on docker-compose and the config looks like:
version: '2'
services:
php-apache:
env_file:
- dev_variables.env
image: reynierpm/php55-dev
build:
context: .
args:
- PUID=1000
- PGID=1000
ports:
- "80:80"
extra_hosts:
- "dockerhost:xxx.xxx.xxx.xxx"
volumes:
- ~/var/www:/var/www
There are some configurations like extra_hosts and env-file that is giving me some headache. Why? Because I don't know if the image will works under such circumstances.
Let's said:
I have run docker-compose up -d and the image reynierpm/php55-dev with tag latest has been built
I have everything working as it should be because I am setting the proper values on the docker-compose.yml file
I have logged in into my account and I push the image to the repository: docker push reynierpm/php55-dev
What happen if tomorrow you clone the repository and try to run docker-compose up but changing the docker-compose.yml file to fit your settings? How the image behaves in this case? I mean makes sense to create/upload the image to Docker Hub if any time I run the command docker-compose up it will be build again due to the changes on the config file?
Maybe I am completing wrong and some magic happen behind scenes but I need to know if I am doing this right
If people clone your git repository and do a docker-compose up -d it will in fact building a new image. If you only want people use your image from docker hub, drop the build section of docker-compose.yml and publish it in your docker hub page. Check this you can see the proposed docker-compose.yml.
Just paste this in your page:
version: '2'
services:
php-apache:
image: reynierpm/php55-dev
ports:
- "80:80"
environment:
DOCKERHOST: 'yourhostip'
PHP_ERROR_REPORTING: 'E_ALL & ~E_DEPRECATED & ~E_NOTICE'
volumes:
- ~/var/www:/var/www
If your env_file just have a couple of variables it is better to show them directly in the Dockerfile. It is better to replace extra_hosts with an environment variable and change in your php.ini or where ever you use the extra host by the variable:
.....
xdebug.remote_host = ${DOCKERHOST}
.....
You can in your Dockerfile define a default value for this variable:
ENV DOCKERHOST=localhost
Hope it helps
Regards

Resources