tounderstand   1189

« earlier    

Connecting to a mysql running on a Docker container · Issue #95 · docker-library/mysql
Frankly, this forum page has no consensus on a solution to this issue. Nevertheless, what worked for me on my set up with running MacOS as the Docker host and running a container with: Ubuntu 16.04 and MySQL 5.7 is the following:

1) Within the container: change in /etc/mysql/mysql.conf.d/mysqld.cnf the bind-address option from 127.0.0.1 to 0.0.0.0
2) Restart MySQL server (note that whenever you start MySQL you must use this command in the Dockerfile:

RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/mysql.conf.d/mysqld.cnf
RUN find /var/lib/mysql -type f -exec touch {} \; && service mysql start

That is, you must touch the files in /var/lib/mysql and then start the server with service command and not systemctl.

Next, create a user separate from root e.g. dev_1, in MySQL and given them privileges to their '0.0.0.0' and '%' hosts. Like this in the Dockerfile:

RUN find /var/lib/mysql -type f -exec touch {} \; && service mysql start && mysql -uroot -proot mysql -e "GRANT ALL ON *.* TO root@'0.0.0.0' IDENTIFIED BY 'secret' WITH GRANT OPTION; CREATE USER 'dev_1'@'0.0.0.0' IDENTIFIED BY 'secret'; GRANT ALL ON *.* TO 'dev_1'@'0.0.0.0' IDENTIFIED BY 'secret' WITH GRANT OPTION; GRANT ALL ON *.* TO 'dev_1'@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION; FLUSH PRIVILEGES;"

Then when you start the container you must publish the port number like so:

docker run -t -d -p 4406:3306 ubuntu_16_04_lemp_php_7_2:latest

If your container stops prematurely, then you might want to add a CMD line in your docker file to run a start.sh script and within that script you might want to add something like this:

# stupid hack to keep container from being stopped
tail -f /dev/null

Finally, to connect to your DB instance on your local MacOS machine with an app like Sequel Pro for example, use the following credentials:

Host: 0.0.0.0
Username: dev_1
Password: <dev_1_password>
Port: 4406

If you don't like to use port 4406, try 3307, 3308, 3309.
github  forum  howto  example  troubleshoot  mysql  server  docker  host  connection  issue  sequel  pro  mariadb  client  hostname  docker-machine  ip  address  ipaddress  guide  reference  toread  tolearn  totry  tounderstand  image  port  detached  database  credentials 
4 days ago by racl101
Docker container will automatically stop after "docker run -d" - Stack Overflow
TLDR: I've tried adding: tail -f /dev/null to my start script and that worked allong with invoking the container with the: docker run -t -d <image-name> command invocation.
stackoverflow  howto  troubleshoot  example  docker  container  automatically  suddenly  stops  running  detached  mode  foreground  workaround  hack  hackfix  fix  toread  tolearn  totry  tounderstand  guide  reference 
4 days ago by racl101
All You Need To Know About Processes in Linux [Comprehensive Guide]
Interesting tutorial giving an introduction to Linux processes that is understandable .
blog  tutorial  toread  tolearn  totry  tounderstand  linux  processes  explanation  guide  reference  overview  system  comprehensive 
4 days ago by racl101

« earlier    

related tags

2.0  accessibility  accessible  address  admin  administrator  advice  algorithms  alternatives  analysis  analytics  animation  ansible  ansynchronous  api  apis  app  application  architecture  aria  arrow  askubuntu  assembly  automate  automatically  aws  axios  backend  basecamp  bash  basic  basics  beginner  beginners  behavior  best  bestpractice  bestpractices  better  blog  books  braces  branches  browser  building  business  cacher  caching  career  careers  caveats  certificate  change  chrome  ci  client  clientside  code  coding  command  commandline  commands  common  communication  company  comparison  compliance  component  components  comprehensive  concepts  concurrent  configuration  connection  container  containers  content  contents  continuous  continuousintegration  core  coreutils  cost  cpus  create  credentials  crud  css  curly  data  database  datasets  design  designing  detached  develoment  developer  developers  development  devops  difference  display  dividing  django  docker-machine  docker  dockerfile  documentation  does  download  driven  dzone  ecmascript  editor  effective  efficiency  elements  end  energy  enhancement  environment  error  errors  es2015  es2016  es2017  es2018  es6  essay  example  examples  exec  execution  explanation  explorer  express.js  express  expressions  expressjs  fallback  features  fetch  files  find  fix  float  floating  footprint  for  foreground  format  forum  framework  frameworks  free  from  front-end  front  frontend  function  functional  functions  fundamentals  future  gdpr  getting  gettingstarted  git  github  gnu  gnutools  good  google  gotchas  gpus  guide  guideline  guidelines  hack  hackfix  host  hostname  howto  howtoforge  http  https  hyperlink  i10n  ideal  image  importance  improve  improvement  in  increase  indicators  integration  interesting  interface  internet  interpolation  interview  introduction  ip  ipaddress  is  issue  java  javascript  jdk  jenkins  job  jobs  julia  key  kit  known  kubernetes  lambda  lamp  language  laravel  learn  learning  less  libraries  library  linkedin  linux  list  listing  localization  locator  logging  machine  macos  macosx  make  man  manpage  manual  mariadb  markdown  master  math  mathematics  mean  medium  memory  message  messaging  microservices  minimal  mistakes  mobile  mode  module  mongodb  multithreading  mysql  network  new  nginx  node.js  node  nodejs  nosql  not  note  observer  on  open  opensource  openssl  opinion  optimization  optimizing  option  order  overview  page  party  pattern  perfect  performance  philosophy  php  php7  pi  plus  port  practice  practices  privacy  private  privileged  pro  problems  processes  product  production  programmer  programming  progressive  project  projects  provisos  proxies  pruning  pseudo  public  pull  python  python2.7  questions  queue  queueing  rabbitmq  rails  raspberry  react  reactjs  read  rebranding  recommendation  recommendations  recover  refactoring  reference  refernce  regex  regular  replace  report  reports  repository  request  resource  resources  restful  rich  right  ror  rsa  rubyonrails  rule  rules  running  runtime  scaling  scheduler  schedulers  science  scientists  screencast  script  search  secure  security  sed  self  sequel  server  serverless  service  setup  shell  sign  signed  skills  software  source  space  sqlite  sqlite3  ssh  stack  stackexchange  stackoverflow  start  started  stateless  statistics  stats  stops  storage  string  struggles  stuff  style  styles  styling  suddenly  suggestion  suggestions  sustainability  swap  syntax  sysadmin  system  systemctl  systemd  taking  tdd  ten  test  testing  tests  text  the  theme  things  third  tips  to  token  tolearn  tool  tools  top  toread  totry  touch  tower  trends  troubleshoot  tutorial  ubuntu  ubuntu16.04  ui  understand  unit  unittesting  unix.stackexchange  unix  use  user  utilities  ux  version  veterans  view  vue.js  vue  vuejs  vuex  web  website  well  what  when  wordpress  work  workaround  workers  workflow  write  wysiwyg  x 

Copy this bookmark:



description:


tags: