I'm using docker-compose to mount a volume on an image. I have the container running, but not able to pull the image in the browser.
Docker-compose has these below lines -
version: '2'
services:
jenkins:
image: image_name
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/gp_oes/project/jenkins_home:/var/jenkins_home
ports:
- 8080
I think you are trying to download the official image of ubuntu (https://hub.docker.com/_/jenkins) which was deprecated since last 2 years.
Please check with the community image of jenkins (https://hub.docker.com/r/jenkins/jenkins)
if it is not the case please provide error with command and image name also to give better understanding of the question.
Related
I am newbie to Docker. I have created Jenkins instance with Docker with jdk1.8 latest image but the URL get down after sometime while the containers are still running. It works after I restart docker service but it also get down eventually after sometime .
Dockerfile
Using official docker image jenkins/jenkins:latest-jdk8 , the only customized item is addition of plugins through Jenkins plugin cli in the image.
To run the instance, docker compose is used with minimal configuration mentioned in image document.
docker-compose.yaml
version: "3.3"
services:
mylocaljenkins:
image: jenkins/jenkins:latest-jdk8
container_name: jc
privileged: true
restart: unless stopped
user: root
port:
- "8080:8080"
- "50000:500000"
volumes:
-/root/mount:/var/jenkins
I am doing my first steps with docker compose and made a docker-compose.yml file which contains:
version: "3.8"
services:
web:
build: ./frontend
ports:
- "3000:3000"
api:
build: ./backend
ports:
- "3001:3001"
environment:
DB_URL: mongodb://db/slip
db:
image: mongo:4.0-xenial
ports:
- "27017:27017"
volumes:
- slip:/data/db
volumes:
slip:
However after running $ docker-compose build
This is my result images in docker:
REPOSITORY TAG IMAGE ID CREATED SIZE
slip_api latest 445199e1e418 43 seconds ago 184MB
slip_web latest c1168ad560b8 About a minute ago 299MB
node 14.16.0-alpine3.13 50bfd284aa0d 10 months ago 117MB
I am not sure why I don't see the mongo:4.0-xenial image, and also not sure why I see the node:14.16.0-alpine3.13 which is a base (FROM) in docker file of the slip_api and slip_web and not an image by itself that I built.
Using Ubuntu 20.04.3 LTS
Thanks for the help!
docker-compose build does literally that: it builds images. In order for an image to be built, the base image needs to present. That is the reason, why you are seeing the node image present.
You do not see the mongoDB image, because it is not built. Once you attempt to docker-compose up it will pull the latest version of mongo:4.0-xenial
How do I find the right compose file version for my docker-compose.yml file?
I have this:
version: '3.7'
services:
ghost:
container_name: ghost
image: ghost:latest
restart: always
ports:
- 127.0.0.1:2368:2368
volumes:
-v /var/www/myBlog/:/var/lib/ghost
and I have installed Docker Engine - Community version: 19.03.8
How can I know it?
Thanks
Are you sure about the -v under your volumes?
Please check the #volume-configuration-reference for docker-compose files.
You need to mention it like below.
volumes:
- /var/www/myBlog/:/var/lib/ghost
You need to change the volume to below
volumes:
- /var/www/myBlog/:/var/lib/ghost
There is a compatibility matrix between Docker Engine and docker-compose
https://docs.docker.com/compose/compose-file/compose-versioning/
Below is the changelog of docker-compose and docker which can help you understand various features available in which version.
Docker-compose:- https://github.com/docker/compose/blob/master/CHANGELOG.md
Docker-ce:- https://github.com/docker/docker-ce/releases
So I'm trying to setup some docker-compose scripts using some of the latest compose 3.5 features. The big one is being able to name networks. So there are some containers that I end up reproducing over and over again, such as a Postgres database, with various apps I work on. My goal is to be able to have a docker-compose script for something like Postgres, with a named network, which I can then have other apps with their own docker-compose scripts just add on to. It feels more re-usable that way.
Anyway, here is the docker-compose script I'm working with:
version: '3.5'
services:
postgres:
image: postgres:11
container_name: postgres
networks:
- pg_network
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=user
ports:
- 5432:5432
volumes:
- ~/.postgresql/data:/var/lib/postgresql/data
- ~/.postgresql/init:/docker-entrypoint-initdb.d
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
networks:
- pg_network
ports:
- 5433:80
environment:
- PGADMIN_DEFAULT_EMAIL=user#gmail.com
- PGADMIN_DEFAULT_PASSWORD=password
volumes:
- ~/.postgresql/pgadmin:/var/lib/pgadmin
networks:
pg_network:
name: pg_network
I am trying to use the "custom name" feature new in Docker Compose 3.5. See this link for the documentation: https://docs.docker.com/compose/networking/
However, when I try to run docker-compose up -d, I get the following error:
ERROR: The Compose file './docker-compose.yml' is invalid because:
networks.pg_network value Additional properties are not allowed ('name' was unexpected)
I'm not sure what I'm doing wrong. I'm on Ubuntu 18.04, I'm running the docker commands with sudo (because that seems to be a requirement on Ubuntu).
Here are my Docker and Docker Compose versions:
Docker version 18.09.2, build 6247962
docker-compose version 1.17.1, build unknown
I've tried upgrading them with APT, but it says they are up to date.
So, either I'm making a mistake in my compose script, or there's something screwy with my Docker version. I would appreciate any insight that can be offered. Thank you.
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