I need to create a docker image with a Dockerfile which is available on a remote computer.
will the below work in Powershell ?
docker build -t MyFirstDockerImage -f //RemoteServerpath/FolderStructure/ .
The docker build can only read local files. But not the remote files. i.e Files should be copied on to the machine where docker build is being executed.
Related
I was trying to delete pg_log folder (it was huge 3Gib) But i accidentally remove everything in data folder (by rm ./*):
Now all of the .conf files removed from data folder and i receiving this error in the log:
"Data page checksums are disabled"
The postgres was made by docker through docker hub (15-alpine)
I didn't touch any config files there.
Where can i find the default postgres config files? I think i can make it back to work by restoring the .conf files.
Steps to recover default config files using Docker image.
Pull docker image for Postrgres:
docker pull postgres:15-alpine
Run container:
docker run -e POSTGRES_HOST_AUTH_METHOD=trust postgres:15-alpine
Keep current terminal open and open new terminal
Connect to shell in docker container:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aee1237294b8 postgres:15-alpine3.17 "docker-entrypoint.s…" 7 seconds ago Up 6 seconds 5432/tcp naughty_knuth
copy container id from docker ps result and execute shell command:
docker exec -it aee1237294b8 bash
Go to data folder and archive it:
cd /var/lib/postgresql/data/
tar -zcf pgdata.tar.gz *
Exit docker container shell:
exit
Copy archive from docker container:
docker cp aee1237294b8:/var/lib/postgresql/data/pgdata.tar.gz ~/Downloads/pgdata.tar.gz
as result I've downloaded config from postgres:15-alpine
grab it from here: https://anarjafarov.me/pg.conf.zip
and watch video instructions: https://www.youtube.com/watch?v=fgHtvwbQJDE
I am starting to use kubernetes/Minikube to deploy my application which is currently running on docker containers.
Docker version:19.03.7
Minikube version: v1.25.2
From what I read I gather that first of all I need to build my frontend/backend images inside minikube.
The image is available on the server and I can see it using:
$ docker image ls
The first step, as far as I understand, is to use the "docker build" command:
$docke build -t my-image .
However, the dot at the end, so I understand, means it is looking for a Dockerfile in the curretn directoy, and indeed I get an error:
unable to evaluate symlinks in Dockerfile path: lstat
/home/dep/k8s-config/Dockerfile: no such file or directory
So, where do I get this dockerfile for the "docker build" to succeed?
Thanks
My missunderstanding...
I have the Dockefile now, so I should put it anywhere and use docker build from there.
I would like to setup my JHipster project on a remote server utilising docker-compose as per here.
Am I right in thinking (for the simplest approach), these are the steps I might follow:
Install docker on remote system.
Install docker-compose on remote system.
On laptop (with app src code) run ./mvnw package -Pprod docker:build to produce a docker image of the application.
Copy the image produced by this to remote server like this.
Install this image on remote system.
On laptop copy relevant yml files from src/main/docker to a directory (e.g. dir/on/remote) on the remote server.
Run docker-compose -f dir/on/remote/app.yml up on the remote server.
Thanks for your help.
Also any suggestions on how this process may be improved would be appreciated.
Expecting that your server is Ubunutu,
SSH to your server,
Install docker, docker-compose, install JAVA and set JAVA_HOME
Two approches
create docker image and push it to docker hub if you have docker hub account
create docker image within server
Second approch would be better to reduce the confusion
Clone your repo to server
cd <APPLICATION_FOLDER>
Do
./mvnw package -Pprod docker:build -DskipTests
List the images created
docker images
You can ignore -DskipTests , if you are writing test code.
Do
docker-compose -f /src/main/docker/app.yml up -d
List containers running
docker ps -a
Logs of the container
docker logs <CONTAINER_ID>
I wish to store my persists data in my local D:\dockerData\postgres9.6. Below is my docker command
docker pull postgres
docker run -d -v /d/dockerData/postgres9.6:/var/lib/postgresql/data -p 5432:5432 postgres
It successful create a container and I can use pgAdmin to access and create database.
But I found out that there is no file in my D:\dockerData\postgres9.6. I exec bash into the container, there is at least 20+ files inside /var/lib/postgresql/data.
Anyone can point out which part goes wrong?
It depends what kind of Docker you are using on Windows:
Docker Toolbox with VirtualBox: only C:\Users\mylogin is shared by default. D:\ is not mounted.
Docker for Windows with HyperV: only C:\ is mounted by default. Make sure D:\ is a shared drive: see image
Is there any way to mount github or other repo's http link as docker volumes, so that when I start my docker container, it would be running with the new code which I've pushed to github or bitbucket ?
You cannot mount such remote resources that are on the Internet.
What you can do is to have a shell script in your docker image which when executed will download those resources. And make docker run that script when the container is run.
Dockerfile
FROM ubuntu:latest
COPY download-from-github.sh /
# your stuff...
RUN bash /download-from-github.sh
download-from-github.sh
curl -sL https://github.com/you/repo/archive/master.zip > /tmp/master.zip
unzip /tmp/master.zip -d /opt