How can I change timezone/time on my running docker private registry container
Host OS: CentOS 7
Docker Version:
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:42:49 2017
OS/Arch: linux/amd64
Experimental: false
Docker registry image: registry:2 ID: a07e3f32a779
Tried execute on container:
export TZ=Europe/Warsaw
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
but without any result for real time.
Same solution works on another containers without any problems.
Any Ideas?
Edit:
Recreated container with compose like this:
apache:
image: "httpd:2.4"
hostname: deleted
restart: always
environment:
- TZ=Europe/Warsaw
ports:
- 5043:5043
links:
- registry:registry
volumes:
- /opt/docker-registry-bundle/auth:/usr/local/apache2/conf
- /etc/timezone:/etc/timezone:ro
registry:
image: registry:2
restart: always
environment:
- TZ=Europe/Warsaw
ports:
- 127.0.0.1:5000:5000
volumes:
- /opt/docker-registry-bundle/registry-data:/var/lib/registry
- /etc/timezone:/etc/timezone:ro
On apache container time is ok.
On registry container still doesn't work.
The following should work when executed inside container:
echo "Europe/Warsaw" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
Solution from sanath
registry:2 image uses alpine base image because of that dpkg command
is missing, refer below link which explains how to change timezone in
alpine based images.
ivankrizsan.se/2015/10/31/time-in-docker-containers ( see Alpine Linux
section )
Related
I'm facing problems trying to mix Windows and Linux containers via docker-compose on a Windows host as demonstrated in https://devblogs.microsoft.com/premier-developer/mixing-windows-and-linux-containers-with-docker-compose/.
I cloned the original repository of the article (https://github.com/RandyPatterson/DockerComposeMultiPlatform) and already replaced each outdated base image from the Dockerfiles with the new links, you can see all relevant files below. I can get it to run manually by first switching to the Linux daemon, spinning up a container for the API, then switching to the Windows daemon and spinning up a container for the web app.
According to https://stackoverflow.com/a/72260359, docker-compose should also do this, including building it for the respective platform and when I run docker-compose up -d on the Windows daemon, it first starts fine by pulling the Linux images for the ApiTier Dockerfile until the first RUN line, where I then get the error hcsshim::CreateComputeSystem 186c82040b2e396b4b6e4c4063c2c8f562e855469630b82415e51043f6cb1773: An adapter was not found.
docker-compose.yml
version: '2.4'
services:
webtier:
image: webtier:win
platform: windows
ports:
- 80
build:
context: .\WebTier
dockerfile: Dockerfile
depends_on:
- apitier
environment:
ApiHost: "apitier"
apitier:
image: apitier:linux
platform: linux
expose:
- 80
build:
context: .\ApiTier
dockerfile: Dockerfile
ApiTier\Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:2.1 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:2.1 AS build
WORKDIR "/src/ApiTier"
COPY . .
RUN dotnet build "WebApi.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "WebApi.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WebApi.dll"]
WebTier\Dockerfile
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2
WORKDIR /inetpub/wwwroot
COPY docker/ .
docker version
Client:
Cloud integration: v1.0.29
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:08:16 2022
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.15.0 (93002)
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.24)
Go version: go1.18.7
Git commit: 3056208
Built: Tue Oct 25 18:03:04 2022
OS/Arch: windows/amd64
Experimental: true
docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
Docker daemon json for Windows
{
"experimental": true,
"features": {
"buildkit": false
}
}
Docker daemon json for Linux
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": true,
"features": {
"buildkit": true
}
}
Steps first, details later:
Switch docker to use Windows containers
In the Docker engine, set experimental to true (I see its already true on your end).
select the "Use Docker Compose V2" in the docker settings (under General).
run the docker-compose up -d command.
The example repo you have shared failed to build on my side, but I found a better example, and it works(with some mods of course :) )
sample docker-compose.yml:
version: '3.8'
services:
nanoserver:
container_name: nanoserver
image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-20H2
sql2017:
container_name: sql2017
platform: linux
mem_limit: 4GB
environment:
- ACCEPT_EULA=Y
- MSSQL_PID=Developer
- SA_PASSWORD=Mypass1.
ports:
- '1433:1433'
image: mcr.microsoft.com/mssql/server:2017-latest
I am using the same docker versions (server and client) as you. However, I think v2 of docker-compose is needed:
$ docker-compose version
Docker Compose version v2.13.0
Make sure to select the "Use Docker Compose V2" in the docker settings.
Refs:
Run Docker for Windows in “mixed” mode by running Windows and Linux containers together
How to enable mixed platform on Docker on year 2022?
---EDITED -- NO LONGER WORKING --- PLEASE HELP---
maybe something is changed in the latest neo4j image (SE MY ANSWER BELOW FOR MORE DETAILS)
I'm try to run neo4j with docker-compose by means of this github repo (that contains the docker-compose.yml)
https://github.com/GraphRM/workshop-neo4j-docker
The docker-compose file conteined in this repo is nothing more that a plain neo4j docker image with some data already attached (you can try yourself, the image is realy small)
Running this file docker-compose up -d (from the folder where the docker-compose.yml file is) seems that all gone well (No errors are showed and the output of the console is Starting workshopneo4jdocker_neo4j_1 ... done)
but in the browser nothing is showed at the following addresses:
localhost:7474
0.0.0.0:7474
127.0.0.1:7474
<dockermachine ip>:7474 got this address with `docker-machine ip`
I suppose is it a network problem (wrong ip address or something related) so i've noted that in the docker-compose.yml file is missing the element network_mode:
docker-compose.yml
version: '3'
services:
neo4j:
image: neo4j:latest
ports:
- "7474:7474"
- "7687:7687"
environment:
- NEO4J_dbms_security_procedures_unrestricted=apoc.*
- NEO4J_apoc_import_file_enabled=true
- NEO4J_dbms_shell_enabled=true
volumes:
- ./plugins:/plugins
- ./data:/data
- ./import:/import
I'd like to modify this file adding network_mode: "bridge" or test with other values (host,none,service:[service name],container:[container name/id])
but the question now is:
how to modify this file if the nano editor is not installed in the neo4j docker image and i can't even install it because apt-get is not installed as well.
(it is a really very minimal image)
Morovere i'm not a linux user so i don't know how to modyfy this file.
May you suggest me the way to modify this file on an image that does't have these tools without using vim?
I'm not so expert with linux but i need to run this docker-compose.yml file provided with the above github repo.
MY ENVIROMENT
Docker Toobox for windows
`docker version`
Client:
Version: 18.01.0-ce
API version: 1.35
Go version: go1.9.2
Git commit: 03596f51b1
Built: Thu Jan 11 22:29:41 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.01.0-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.2
Git commit: 03596f5
Built: Wed Jan 10 20:13:12 2018
OS/Arch: linux/amd64
Experimental: false
PS: do you think the problem is not related to the ip address?
>>>>>EDITED<<<<<
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
38e06d1020d8 neo4j:latest "/docker-entrypoint.…" 30 hours ago Up 29 minutes 0.0.0.0:7474->7474/tcp, 7473/tcp, 0.0.0.0:7687->7687/tcp workshopneo4jdocker_neo4j_1
Adding network_mode: "bridge" to the docker-compose.yml file and accessing to the docker-machine ip the image works correctly
docker-compose.yml
version: '3'
services:
neo4j:
image: neo4j:latest
network_mode: "bridge"
ports:
- "7474:7474"
- "7687:7687"
environment:
- NEO4J_dbms_security_procedures_unrestricted=apoc.*
- NEO4J_apoc_import_file_enabled=true
- NEO4J_dbms_shell_enabled=true
volumes:
- ./plugins:/plugins
- ./data:/data
- ./import:/import
Below yml file work fine to me. Yes it is not very fast and you have to wait for 2-3 minutes for it to come up and available to browser at http://localhost:7474/browser
version: '3'
services:
neo4j:
image: neo4j:4.3.3-community #4.3.3-community latest
container_name: neo4j
ports:
- "7474:7474"
- "7687:7687"
networks:
- ecosystem_network
environment:
- NEO4J_AUTH=neo4j/eco_system
- NEO4J_dbms_memory_pagecache_size=512M
volumes:
- ${HOME}/neo4j/data:/data
- ${HOME}/neo4j/logs:/logs
- ${HOME}/neo4j/import:/var/lib/neo4j/import
- ${HOME}/neo4j/plugins:/plugins
networks:
ecosystem_network:
driver: bridge
I'm trying to setup docker & compose for running integration tests
I have the following docker-compose.yml
version: '3'
services:
tests:
build:
context: .
dockerfile: Dockerfile.tests
links:
- web
- maindb
web:
build:
context: .
dockerfile: Dockerfile.web
ports:
- "8080:8080"
volumes:
- .:/code
- logvolume01:/var/log
links:
- maindb
maindb:
image: postgres
environment:
POSTGRES_PASSWORD: example
volumes:
logvolume01: {}
web container itself works pretty fine
$ docker-compose -p wh run web
Starting wh_maindb_1 ... done
2017/07/27 22:05:34 [I] http server Running on http://:8080
But when I run tests container, I get the error
$ docker-compose -p wh run tests
Starting wh_maindb_1 ... done
Starting 6faff07f7671_6faff07f7671_wh_web_1 ...
Starting 6faff07f7671_6faff07f7671_wh_web_1 ... error
ERROR: for 6faff07f7671_6faff07f7671_wh_web_1 Cannot start service web: oci runtime error: container_linux.go:262: starting container process caused "exec: \"web\": executable file not found in $PATH"
Here is my Dockerfile.web
$ cat Dockerfile.web
FROM ubuntu:xenial
WORKDIR /app
ADD bin/* /app/
CMD ["/app/web"]
/app/web is dynamically linked daemon written in Golang 1.6
And some version info
$ docker version
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:23:31 2017
OS/Arch: linux/amd64
Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:19:04 2017
OS/Arch: linux/amd64
Experimental: false
$ docker-compose version
docker-compose version 1.14.0, build c7bdf9e
docker-py version: 2.4.2
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
This is maybe related to some docker-compose bug.
Try cleaning containers
docker-compose down
Alternatively this (you will lose your container data):
docker rm -f $(docker ps -a -q)
I am trying to run haproxy in a docker container. To build and run the haproxy from the image, docker-compose reads my .yaml file below.
proxy:
build: ./
env_file: .env
ports:
- "8000:80"
- "9000:9000"
After executing a docker-compose build, the image is created but while trying to spawn a container using the following, I am getting the following errors:
$ docker-compose up -d
Starting my_haproxy_container
←[31mERROR←[0m: Container command could not be invoked.
By docker install information:
$ docker version
Client:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Mon Feb 22 22:37:33 2016
OS/Arch: windows/amd64
Server:
Version: 1.10.3
API version: 1.22
Go version: go1.5.3
Git commit: 20f81dd
Built: Thu Mar 10 21:49:11 2016
OS/Arch: linux/amd64
I am not sure why the docker-compose up -d is unable to bring up the container. Any information is much appreciated. Thank you.
Container command could not be invoked
Is means you have problems with CMD in your Dockerfile. It is not docker-compose problem.
Incorrect CMD command
Command in CMD tries to run file without -execute permission
Check you ./Dockerfile
I am doing this on a AWS Linux Instance
Client:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5/1.9.1
Built:
OS/Arch: linux/amd64
Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5/1.9.1
Built:
OS/Arch: linux/amd64
Whenever I try to docker-compose up -d with the following docker-compose.yml (this is an excerpt)
elasticsearch:
image: elasticsearch:2.1.1
command: elasticsearch
ports:
- "9200:9200"
- "9300:9300"
volumes:
- ./elk/es/staging.yml:/etc/elasticsearch/elasticsearch.yml
links:
- kibana
volumes_from:
- es-data
es-data:
image: elasticsearch:2.1.1
command: "true"
volumes:
- /usr/share/elasticsearch/
- /etc/default/elasticsearch
- /var/lib/elasticsearch/
- /var/log/elasticsearch
I'll receive this error:
Recreating es-data_1
ERROR: cannot mount volume over existing file, file exists /var/lib/docker/devicemapper/mnt/33111596cd765c4220c65ea7cc35df4a6c295a860e4ad94294c7ee985da6ea7c/rootfs/etc/default/elasticsearch
I've tried bypassing this error by removing the volumes from es-data, but that is not ideal as I'm using it as a data only container.
I've tried removing all the volumes available on the system using docker volume rm $(docker volume ls -q), but that removes all of the volumes except one that I am not sure how to force remove.
Ideal situation would be to allow me to reuse that volume (which I'm assuming is orphaned at this point). Second ideal situation would be able to remove the volume and be able to create a new one.
If I was doing this on my personal machine, I would take the easier approach of recreating the docker-machine I am using as a clean slate, but I don't want to do that on my AWS instance.