Docker

1083 readers
1 users here now

founded 1 year ago
MODERATORS
26
 
 

cross-posted from: https://programming.dev/post/11703185

cross-posted from: https://programming.dev/post/11703178

In this article, we’ll examine cache misses and, in general, learn about the caching concept and how to implement it in Spring Boot.

27
 
 

Note: video sponsored by Docker

28
29
 
 

cross-posted from : https://lemmy.pierre-couy.fr/post/350920

I am trying to come-up with a reusable template to quickly start new projects using my prefered tools and frameworks, and I'm happy with what I got. However, using Docker is quite new for me and I've probably done some weird or unconventional stuff in my docker-compose.yml or my Dockerfiles. I'd love to learn from people with more experience with Docker, so feel free to tell me everything that is wrong with my setup.

I'm more confident about the stuff I did with Python/Django and Nuxt, but all criticism is welcome. This also applies to the readme : I'd like to provide detailed instructions about working with this project template, so please report anything that is unclear or missing.

Thank you to anyone who takes the time to check it out and help me make this useful to as many people as possible.

30
 
 

Is it possible to create a volume that is a file, not a directory?

I am trying to make a simple structured nginx instance with docker. Using this command below to create the container...

docker container create -v ./nginx.conf:/etc/nginx/conf.d/nginx.conf -v .:/app/ -p 80:80 docker.io/nginx

And this is the file structure of it...

- www
-------------- public
---------------------------- index.html
- nginx.conf

And this is the nginx.conf

server {
    server_name localhost;
    listen 80;
    
    root /app/www/public;

    index index.html index.htm;
    autoindex on;
}

However the index.html will not work when I go to the localhost.

When I change the docker command to this it does work however, but this will also mirror all of the files and folder from my file structure into the containers /etc/nginx/conf.d/ directory

docker container create -v .:/etc/nginx/conf.d/ -v .:/app/ -p 80:80 docker.io/nginx
31
 
 

cross-posted from: https://programming.dev/post/10005452

cross-posted from: https://programming.dev/post/10005448

Things you can do right now to learn new and valuable things that can improve your code.

32
 
 

Learn about the latest Docker Desktop feature, synchronized file shares, which provides native file system performance, improving file operation speeds by 2-10x.

33
 
 

The Docker team announces the general availability of docker init, with support for multiple languages and stacks, making it simpler than ever to containerize your applications.

34
10
submitted 7 months ago* (last edited 7 months ago) by [email protected] to c/docker
 
 

I am looking for something that can take a Dockerfile, like the following as an input:


FROM --platform=linux/amd64 debian:latest
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y curl unzip libsecret-1-0 jq
COPY entrypoint.sh .
ENTRYPOINT [ "/entrypoint.sh" ]

And produce a a multi-stage Dockerfile where the last stage is built from scratch, with the dependencies for the script in the ENTRYPOINT (or CMD) copied over, like this:


FROM --platform=linux/amd64 debian:latest as builder
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y curl unzip libsecret-1-0 jq

FROM --platform=linux/amd64 scratch as app
SHELL ["/bin/bash"]

# the binaries executed in entrypoint.sh
COPY --from=builder /bin/bash /bin/bash
COPY --from=builder /usr/bin/curl /usr/bin/curl
COPY --from=builder /usr/bin/jq /usr/bin/jq
COPY --from=builder /usr/bin/sleep /usr/bin/sleep

# shared libraries of the binaries
COPY --from=builder /lib/x86_64-linux-gnu/libjq.so.1 /lib/x86_64-linux-gnu/libjq.so.1
COPY --from=builder /lib/x86_64-linux-gnu/libcurl.so.4 /lib/x86_64-linux-gnu/libcurl.so.4
COPY --from=builder /lib/x86_64-linux-gnu/libz.so.1 /lib/x86_64-linux-gnu/libz.so.1
# ...a bunch of other shared libs...

# entrypoint
COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]

I've had pretty decent success creating images like this manually (using ldd to find the dependencies) based on this blog. To my knowledge, there's nothing out there that automates producing an image built from scratch, specifically. If something like this doesn't exist, I'm willing to build it myself.

35
36
 
 

I just installed Immich and while all my other containers have just required me to add to them to existing yaml, Immich requires its own yaml. That's fine I guess, but for the library, I wanna host it on my NAS and so I made the volume in my main Docker-Compose.yaml, the Immich yaml was all like, "what you talking about Willis?" because in my Immich environment I tried to point to something created in my main yaml. I thought I could work around this by adding an empty volume declaration, but now I can't find my uploads 😂 any idea on the correct methodology/workaround?

37
18
submitted 8 months ago by starman to c/docker
 
 

Whether you’re a Docker expert or new to the Docker community, you may be wondering about the best ways to optimize or get started quicker on Docker. Docker Captain Vladimir Mikhalev rounds up top Docker tips to help you supercharge developer productivity in 2024.

38
 
 

How did your journey begin? I feel like Docker has been getting mentioned for aeons and I've only just started using it now.

39
 
 

I know this seem like a typical "Your opinion man" post but honestly, is there anything really useful beyond hosting an adblocker? (read: complementary, not found elsewhere, that enhances own's personal needs and/or life as a whole). And yes, I'm aware of what can be hosted -- picture editors, video editors, webtops, dhcpcd, emulators, and so on.

But the question is -- why I'd need all that if these stuff can be found on any ordinary PC out there? Even phones. Hell, even on a smart tv. That is like "trying to reinvent the wheel" for no necessary purpose other than "to look cool". There's also "because its fun", but is it really fun doing pretty much the same thing over and over again? There isn't a "learning gap" between these hosting options -- all of em have (pretty much) the same procedure to get things running.

With that said... I've been trying really, REALLY hard to host more stuff but I can't go beyond hosting (only) an adblocker.

40
41
42
43
44
2
submitted 9 months ago* (last edited 9 months ago) by [email protected] to c/docker
 
 

Not sure what I'm doing wrong here, I'm using this image:

https://hub.docker.com/r/bitnami/wordpress-nginx

I updated the compose file to have un/pw for mariadb:

  mariadb:
    image: docker.io/bitnami/mariadb:11.1
    volumes:
      - '/etc/docker/mariadb-persist:/bitnami/mariadb'
    environment:
      - ALLOW_EMPTY_PASSWORD=no
      - MARIADB_USER=admin
      - MARIADB_PASSWORD=admin
      - MARIADB_DATABASE=bitnami_wordpress

But I get this error:

2023-12-03 19:03:02 3 [Warning] Access denied for user 'admin'@'172.18.0.3' (using password: NO)

using password: NO??

45
46
 
 

Hello Lemmy,

I have to grade student work. Students who have made their first springboot applications. I'm wary for idiots who don't understand anything about java, yet somehow manage to include code that wipes my entire User folder, so I run the projects in docker these days.

One criterium is that they include a upload/download functionality. Some students decide to do that by storing the files in the DB, other store it in an "uploads" folder.

The first one works fine in docker. The second one not so much. The java code refers to a path "sourceroot/uploads", but that doesn't exist in the docker container. How can I make it exist in the docker container?

This is the DOCKERFILE I use to docker build -t image .

FROM eclipse-temurin:17-jdk-alpine
VOLUME /tmp
EXPOSE 8080
EXPOSE 5432
COPY target/*.jar application.jar
ENTRYPOINT ["java", "-jar", "application.jar"]

This is the yaml I use to run docker compose up -d

version: '2'

services:
  app:
    image: 'image'
    ports: 
        - "8080:8080"
    container_name: app
    depends_on:
      db:
        condition: service_healthy
    environment:
      - SERVER.PORT=8080
      - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/testing
      - SPRING_DATASOURCE_USERNAME=postgres
      - SPRING_DATASOURCE_PASSWORD=postgres
      - SPRING_JPA_HIBERNATE_DDL_AUTO=create-drop
          
  db:
    image: 'postgres:13.1-alpine'
    ports:
      - "5432:5432"
    expose: 
      - "5432"
    container_name: db
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_HOST_AUTH_METHOD=trust
      - POSTGRES_DB=testing
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5
  

networks:
  default:
    name: docker

I'm sorry if this code offends anybody. I've made this Frankenstein's monster myself from bits and pieces. However, I can't seem to figure out how to add a working "uploads folder" to it that could be used by the springboot application inside the container. Any help would be appreciated.

47
 
 

What does the -d mean in the run command?

docker run -d -p 3355:3355/tcp -p author/image
48
 
 

I'm very new to Docker and Linux in general. My goal was to make my own server mainly for Plex. Now that I've got that running with the help of Dockstarter, I'm looking to branch out and I want to make sure my system is secure. I'm also running Ubuntu 'cause I for sure couldn't get this far with Terminal alone.

I use Private Internet Access as my VPN and I have it installed on my desktop environment. I've also been able to reroute my qBittorrent in a container through another container with Gluetun.

My prior setup is a Windows machine with PIA, kill switch enabled, qBit assigned to PIA adapter only.

So my question: What is more secure, PIA running on Ubuntu with a kill switch or tunneling each container through Gluetun?

I would like it to mirror my Windows setup but I couldn't figure out the network adapter situation with qBit.

49
 
 

For example I have a docker compose stack with a service and a db.
How do you handle the passwords? Is it better to store them in a .env file or is there something different entirely?

Also do the passwords have to be strong if the db is only available to the service through the docker network?

50
 
 

According to the documentation to change the Portainer address and Edge agent talks to, you have to redeploy the Edge agent. If I understand properly this is going to assign the agent a new ID and will blow away the configuration.

Does anyone know how to do this while retaining the stack configurations?

view more: ‹ prev next ›